Wildcard find & replace??

General discussions about Advanced Find and Replace
Post Reply
irbrian

Wildcard find & replace??

Post by irbrian » Mon Jan 31, 2005 5:32 pm

I need to replace a large number of lines in a program I'm writing that are similar, but have differing values. For instance:

Code: Select all

function hello ()
{
  MyVar1 = 'testvalue';
  MyVar2 = SUPER[1];
}

MyVar1 = 'value2';
MyVar2 = AnotherVar;

I need to replace all occurences of:

MyVar1 = '*';
MyVar2 = *;

with:

myFunc1 ('*', *);

So that the resulting code reads:

Code: Select all

function hello ()
{
  myFunc1 ('testvalue', SUPER[1]);
}

myFunc1 ('value2', AnotherVar);


Does that make sense, and is it possible to accomplish with AFR? If so I'll buy the program in a heartbeat ;) Alert Wildcard does this, but I like AFR a lot better overall.

Abacre
Site Admin
Posts: 1201
Joined: Mon Jan 31, 2005 5:32 pm
Contact:

Post by Abacre » Mon Jan 31, 2005 5:32 pm

It's pretty easy:

Search for:
MyVar1 = (.*);.*MyVar2 = (.*);

Replace with:
myFunc1 ($1, $2);

I verified and it works well.

Be sure that "S" modifier is ON.

Abacre
Site Admin
Posts: 1201
Joined: Mon Jan 31, 2005 5:32 pm
Contact:

Post by Abacre » Mon Jan 31, 2005 5:32 pm

BTW, it will be wiser to use

Search for:
MyVar1.*=.*(.*);.*MyVar2.*=.*(.*);

So you don't cafe about spaces.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests