PDA

View Full Version : 3.0.10 replacement item and tagged text


hartungr
06-Nov-2008, 10:17 AM
Win XP SP3. Using $1 in "replace with" field ends matching.

Left file:
tag is 3I
using tag=3I

Right file:
tag is 3J
using tag=3J

I wanted a single text replacement to look for "(=| )3I" (left side) and replace it with "<matching char>3J"
so that "=3I" would equate to "=3J" and " 3I" equates to " 3J"

The RE expression on left is correct and matching occurs, as long as I am explicit on the right. When I add the $1 on the right, it no longer matches.

Thanks

Erik
06-Nov-2008, 10:42 AM
Your "Replace with:" should be "$1\3J" (instead of "$13J"). You need the "\" because otherwise the expression tries to use the 13th tagged expression, which doesn't exist.

hartungr
06-Nov-2008, 10:47 AM
thanks, Erik - makes sense, and works.

Any chance that ${1} could be supported?

Erik
06-Nov-2008, 11:43 AM
What do you expect "${1}" to do? I'm unable to find any documentation that mentions special behavior for it ($ means match end of line, {1} means match the previous patter exactly once). We use a third-party perl-compatible regular expression library.

hartungr
06-Nov-2008, 12:19 PM
I was thinking of the right side of a perl re substitution, where $1 can be written as ${1} to disambiguate.

# perl -e '$t="current tag=3I"; $t =~ s/.*?(=| )3I/${1}3J/; print $t . "\n"'
=3J