Is it possible to repeat a 'replace all' untill 'Search string not found' occurs? (Macro?) And indicate a max number of iterations. (to avoid infinite loops)
Repeat 'replace all' until 'Search string not found' occurs
Repeat 'replace all' until 'Search string not found' occurs
This basic structure?
Loop
Find "find string"
IfNotFound
ExitLoop
EndIf
Replace "replace string"
EndLoop
Loop
Find "find string"
IfNotFound
ExitLoop
EndIf
Replace "replace string"
EndLoop
Software For Metalworking
http://closetolerancesoftware.com
http://closetolerancesoftware.com
Re: Repeat 'replace all' until 'Search string not found' occurs
Hi mrainey56!
Your code will not be compiled by UltraEdit because a Replace command can be only immediately after a Find command. But following will work:
Loop x
Find "find string"
Replace All "replace string"
IfNotFound
ExitLoop
EndIf
EndLoop
I use this very often in my macros. Specify for x the maximum number of iterations. But most Replace All must be executed only once. My macros to delete all blank lines at Deleting blank lines using Perl regular expressions shows an exception where a Replace All in a Loop is really needed.
Just for your info: As DaveS detected, every Find in a macro is in real a Find with Replace with identical search and replace string. You can see that if you view a macro file in hex edit mode which contains only 1 Find but the find string is twice in the file. So IfFound and IfNotFound can be also used immediately after a Replace command because internally a Find only is in real also a Find with Replace.
Your code will not be compiled by UltraEdit because a Replace command can be only immediately after a Find command. But following will work:
Loop x
Find "find string"
Replace All "replace string"
IfNotFound
ExitLoop
EndIf
EndLoop
I use this very often in my macros. Specify for x the maximum number of iterations. But most Replace All must be executed only once. My macros to delete all blank lines at Deleting blank lines using Perl regular expressions shows an exception where a Replace All in a Loop is really needed.
Just for your info: As DaveS detected, every Find in a macro is in real a Find with Replace with identical search and replace string. You can see that if you view a macro file in hex edit mode which contains only 1 Find but the find string is twice in the file. So IfFound and IfNotFound can be also used immediately after a Replace command because internally a Find only is in real also a Find with Replace.
Best regards from an UC/UE/UES for Windows user from Austria
Guys,
thank you very much. Works fine!
But, regarding the speed at which you have replied with these answers (approx. 2 hours), one word: Amazing.
cu
thank you very much. Works fine!
But, regarding the speed at which you have replied with these answers (approx. 2 hours), one word: Amazing.
cu
Thanks for the correction Mofi. That's what I get for not testing!
Software For Metalworking
http://closetolerancesoftware.com
http://closetolerancesoftware.com