Re: attn: regex gurus. can this be done with a regular expression or using a different technique?



Thanks to Larry and Frans for their help.

Larry, your suggestion worked very well. Just had to make one change.
Apparently, (for some reason!?!?) Microsoft decided to switch the capture
characters from parentheses to brackets when using regular expressions
within Visual Studio's search/replace functionality.

So the final expressions that worked are:
Search: Test\({.*}, {.*}\)
Replace: Test(\2, \1)

Thanks Again!
Chris

<larrylard@xxxxxxxxxxx> wrote in message
news:1119517859.684122.171280@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>
>
> ChrisB wrote:
>> Hello:
>>
>> A third party component (NUnit) being used by my c# code has undergone a
>> breaking change and, as a result, thousands of methods calls in my source
>> code need to be revised in the following way:
>>
>> // General example of the desired revision
>> RevisedMethod(stringA, stringB) // prior to change
>> RevisedMethod(stringB, stringA) // after change
>>
>> Basically, I need to switch *whatever* appears before the comma with
>> *whatever* appears after the comma. This change needs to take place in
>> literally thousands of places, and I was wondering if it is possible to
>> somehow accomplish the switch using the Visual Studio regex search and
>> replace feature. If so, what would the expression look like?
>
> Try this:
>
> Find:
> RevisedMethod\((.*), (.*)\)
>
> Replace:
> RevisedMethod(\2, \1)
>
> The ( ) in the Find expression 'tag' the captured texdt within, then
> the \1 \2 in the Replace expression refer to the 1st and 2nd such
> tagged strings from the Find.
>
> --
> Larry Lard
> Replies to group please
>


.



Relevant Pages

  • a simple test. dont look
    ... > Thanks to Larry and Frans for their help. ... > characters from parentheses to brackets when using regular expressions ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: In-Out Parameters for functions
    ... expressions with two or more impure function calls would need to switch ... your compiler vendor to put in a switch--the result of turning on the ... switch would still be a legal implementation of Ada. ...
    (comp.lang.ada)
  • Re: Why I will never shop at Wal Mart again
    ... >>By selling Larry a different item, and by not fixing the error when it ... WalMart committed fraud against Larry. ... that would be the incorrect camera in the box that Larry paid for. ... > switch than that the package was mispacked by the manufacturer. ...
    (rec.photo.digital)
  • Re: I dont understand enums
    ... Eclipse complaining that "case expressions must be constant expressions". ... which means *compile time* constants. ... you might recompile PlaylistType ... However, you can switch on enums too, so change the switch to do ...
    (comp.lang.java.programmer)
  • Re: Access 2K and Access 97 on same machine
    ... Hi Larry, ... > longer startup time as when you switch between versions, ... Had this annoying problem and found a post on google regarding .srg files ...
    (microsoft.public.access.gettingstarted)