Loading ...
Sorry, an error occurred while loading the content.
 

RE: [Clip] RegEx Question: Matching Variable Length Replacments

Expand Messages
  • John Shotsky
    This isn t completely without a loop, but it does work: ^!Replace BC* KA C ARSW ^!IfError Next Else Skip_-1 Regards, John RecipeTools Web Site:
    Message 1 of 5 , Aug 5 12:59 PM
      This isn't completely without a loop, but it does work:
      ^!Replace "BC*\KA" >> "C" ARSW
      ^!IfError Next Else Skip_-1

      Regards,
      John
      RecipeTools Web Site: <http://recipetools.gotdns.com/> http://recipetools.gotdns.com/

      From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of Art Kocsis
      Sent: Sunday, August 05, 2012 05:01
      To: NoteTab-Clips
      Subject: [Clip] RegEx Question: Matching Variable Length Replacments


      I am trying to do what (I think), should have been a simple
      RegEx find and replace but can't figure out the way to do it.

      I want to change variable length lines like the following:

      BAAAAAAAz AAAAAA
      BAAAAAz AAAA
      BAAAAAAAAAz AAAAAAA

      to

      BCCCCCCCz AAAAAA
      BCCCCCz AAAA
      BCCCCCCCCCz AAAAAAA

      I.E, change all the "A"s between the "B" and the "z" to "C"s

      I have already coded a work around by using a loop.

      My question is how to do this with a single RegEx F&R.

      Either ^!Replace "(B|C)A" >> "$1C" AIRSTW
      or ^!Replace "(?<=(B|C))A" >> "C" AIRSTW

      will change the first remaining target "A" in each line to a "C"
      but requires a loop to change them all.

      If I use an indeterminate qualifier, such as

      ^!Replace "(B|C)A+?" >> "$1C" AIRSTW

      it will replace all of the "A"s with a single "C"

      How does one "count" the length of a matched pattern
      and then use that count in the replacement? Is there a
      way to "loop" within RegEx or do a recursive F&R?

      IN general, how does one use RegEx to replace a variable
      length matched pattern (or variable count matched pattern)
      with an equal length (count) replacement pattern?

      Namaste', Art



      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.