Regexp search/replace doesn't replace all occurrences

Find, replace, find in files, replace in files, regular expressions

Regexp search/replace doesn't replace all occurrences

Postby emmchild » Tue May 24, 2005 10:39 am

I use the macro below to replace double quotation marks (") that are not next to a comma not (",) or (",) with the string "(qt)".

It works, except that a series such as the following

4*6 "Butterfly" "Botanical" frame

gets translated to this

4*6 (qt)Butterfly(qt) "Botanical(qt) frame

It ignores the third quotation mark. If I run the macro again, it changes the last quotation mark.

Something is wrong with my regexp. The third quotation mark is not satisfying the search condition for some reason. But I don't know why. Can anyone spot the problem?

Code: Select all
InsertMode
ColumnModeOff
HexOff
UnixReOn
Top
Find RegExp "([^,])"([^,])"
Replace All "\1(qt)\2"
emmchild
 

Re: Regexp search/replace doesn't replace all occurrences

Postby ASTTMan » Tue May 24, 2005 12:18 pm

I believe this is caused by one matching string overlapping the other. For example, the second quote was matched by the string /y" /, and the third quote presumably by / "B/. But the same space is in both (supposedly) matching strings. I believe that UE skips the matched string before searching for the next in a replace all operation. (I tried it using successive Find Next operations and it also skipped the third quote. I tried it backwards, starting from the bottom, and it hit the third, but skipped the second.)

I am not aware of any work around other than to do the replace multiple times until it fails. Maybe someone else has a better solution.

Dave
User avatar
ASTTMan
Basic User
Basic User
 
Posts: 26
Joined: Fri Feb 18, 2005 12:00 am
Location: Arlington, TX


Return to Find/Replace/Regular Expressions