Regexp search/replace doesn't replace all occurrences

Regexp search/replace doesn't replace all occurrences

emmchild

    May 24, 2005#1

    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"

    261
    Basic UserBasic User
    261

      May 24, 2005#2

      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
      ASTTMan
      I'm not a Texan, I just live here.