replace using tagged expressions

Help with writing and playing macros

replace using tagged expressions

Postby kezzemil » Tue Oct 03, 2006 8:57 am

I got a textfile like this

"
set [$APPL_CODE] = SLP
set [$MYSQL_SERVER] = ecarl0.bc
set [$MYSQL_PORT] = 304
set [$DB_DISK_QUOTA] = 00Mb

in [$MYSQL_server]
logon with ssh e.g. from ecar0o.bc with ssh mysql@[$MYSQL_SERVER]
(password is the same as for oracle-user)
verify that the new filesystems are owned by mysql:mysql :
/users/application/mydb[$MYSQL_PORT]
"
off course with a lot more codes and text.
I want to replace every occurence of text between [] with the value assigned to it in the "set " line.

I created a macro like this

"
InsertMode
ColumnModeOff
HexOff
UnixReOff
Find RegExp "set ^(^[^$MYSQL_SERVER^]^) = ^(*^) ^p"
Find RegExp "^1"
Replace All "^2"
Find RegExp "set ^(^[^$MYSQL_PORT^]^) = ^(*^) ^p"
Find RegExp "^1"
Replace All "^2"
Find RegExp "set ^(^[^$WEB_SERVER^]^) = ^(*^) ^p"
Find RegExp "^1"
Replace All "^2"
"

but apparantly the second find where he looks for tagged expression 1 fails (although it exists)
Can someone help me out ?
User avatar
kezzemil
Newbie
 
Posts: 2
Joined: Mon Oct 02, 2006 11:00 pm

Re: replace using tagged expressions

Postby Mofi » Tue Oct 03, 2006 1:16 pm

Read the help of UltraEdit more carefully. The codes ^1^2^3 ... cannot be used in a search string, only in a replace string. What I think you want to do (always good to have an example before and after macro execution) could be done with following macro:

InsertMode
ColumnModeOff
HexOff
Find "set [$MYSQL_SERVER] = "
StartSelect
Key END
EndSelect
Find "[$MYSQL_SERVER]"
Replace All "^s"
Find "set [$MYSQL_PORT] = "
StartSelect
Key END
EndSelect
Find "[$MYSQL_PORT]"
Replace All "^s"
Find "set [$WEB_SERVER] = "
StartSelect
Key END
EndSelect
Find "set [$WEB_SERVER] = "
Replace All "^s"
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4039
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: replace using tagged expressions

Postby kezzemil » Thu Oct 05, 2006 6:46 am

Thanks Mofi
This does the trick (with some minor modifications)
User avatar
kezzemil
Newbie
 
Posts: 2
Joined: Mon Oct 02, 2006 11:00 pm


Return to Macros