This topic is 3939 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Often I need to go from something like: var = foo( a, b ); to foo( var, a, b ); Or something like this, where the calling convention has changed. Any idea of an easy way to do this w/o external scripting? (VS2005's reg expressions in their find/replace?) [VS2005/C++]

theTroll

##### Share on other sites
Quote:

Ok those are some cool tips, but I need to do this en masse to the whole document, which it doesn't explain how to do. (The transpose is cool, and close, but no cigar.)

I can easily use regex's to remove things, i.e. go from

var = foo( a, b );

to

foo( a, b );

using a wildcard to spot variables like "var". But I don't know how to preserve that var name and move it somewhere (like into a first parameter).

Thanks if anyone else has ideas..

##### Share on other sites
Pretty sure you can do it with regex. Let me take a look at it and get back to ya..

theTroll

##### Share on other sites
You can do with substitutions in Regex.

theTroll

##### Share on other sites
I'm 99% sure you can do it with a VB macro, from the VS macro explorer, which is pretty convenient, but those are slow. :(

##### Share on other sites
Quote:
 Original post by discman1028But I don't know how to preserve that var name and move it somewhere (like into a first parameter).

Look at the "{} Tag expression" feature of regular expressions.

##### Share on other sites
I entered
Find what: {:w} = {(:w)}$${.*}$$;
Replace with: \2( \1,\3)
(the { } capture strings, \n refers to the n-th captured string). Using this converted
var = foo( a, b );bar = x( 1, 2, 3 );z = test( func(55, 6), 5 + 9 );
into
foo( var, a, b )x( bar, 1, 2, 3 )test( z, func(55, 6), 5 + 9 )

which I believe you're after. You might have to add some extra stuff in your regex depending on your exact needs.

##### Share on other sites
Too cool guys, thanks!

##### Share on other sites
Quote:
 Original post by SamLowryI enteredFind what: {:w} = {(:w)}$${.*}$$;Replace with: \2( \1,\3)(the { } capture strings, \n refers to the n-th captured string).

Where do I find more options like :w? (What's :w mean?) It worked well, but sometimes it doesn't grab an alphanumeric string, only the alpha part.

1. 1
Rutin
46
2. 2
3. 3
4. 4
5. 5
JoeJ
19

• 11
• 15
• 9
• 10
• 13
• ### Forum Statistics

• Total Topics
633004
• Total Posts
3009836
• ### Who's Online (See full list)

There are no registered users currently online

×