I don't think this is possible with just regular expressions, but I'm not an expert so i thought it was worth asking.
I'm trying to do a massive search and replace of C# code, using .NET regex. What I want to do is find a line of code where a specific function is called on a variable that is of type DateTime. e.g:
axRecord.set_Field("CreatedDate", m_createdDate);
and I would know that it's a DateTime variable b/c earlier in that code file would be the line:
DateTime m_createdDate;
but it seems that I can't use a named group in negative lookbehind like:
(?<=DateTime \k<1>.+?)axRecord.set_[^ ]+ (?<1>[^ )]+)
and if I try to match the all the text between the variable declaration and the function call like this:
DateTime (?<1>[^;]+).+?axRecord.set.+?\k<1>
it will find the first match - first based on first variable declared - but then it can't find any other matches, because the code is laid out like this:
DateTime m_First;
DateTime m_Second;
...
axRecord.set_Field("something", m_First);
axRecord.set_Field("somethingElse", m_Second);
and the first match encompasses the second variable declaration.
Is there a good way to do this with just regular expressions, or do I have to resort to scripting in my logic?