Jump to content
  • Advertisement
Sign in to follow this  
discman1028

Advanced Find + Replace

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

If you intended to correct an error in the post then please contact us.

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++]

Share this post


Link to post
Share on other sites
Advertisement
This article should help; http://visualapl.com/library/aplnext/mergedProjects/Visual%20Studio%20Book/Visual_Studio.htm

theTroll

Share this post


Link to post
Share on other sites
Quote:
Original post by TheTroll
This article should help; http://visualapl.com/library/aplnext/mergedProjects/Visual%20Studio%20Book/Visual_Studio.htm


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 this post


Link to post
Share on other sites
Quote:
Original post by discman1028
But 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 this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by SamLowry
I entered
Find 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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!