3.0.10 replacement item and tagged text

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hartungr
    Enthusiast
    • Apr 2005
    • 47

    3.0.10 replacement item and tagged text

    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
    Team Scooter
    • Oct 2007
    • 437

    #2
    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.
    Erik Scooter Software

    Comment

    • hartungr
      Enthusiast
      • Apr 2005
      • 47

      #3
      thanks, Erik - makes sense, and works.

      Any chance that ${1} could be supported?

      Comment

      • Erik
        Team Scooter
        • Oct 2007
        • 437

        #4
        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.
        Erik Scooter Software

        Comment

        • hartungr
          Enthusiast
          • Apr 2005
          • 47

          #5
          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

          Comment

          Working...