RE: [Clip] RegEx Question: Matching Variable Length Replacments
- This isn't completely without a loop, but it does work:
^!Replace "BC*\KA" >> "C" ARSW
^!IfError Next Else Skip_-1
RecipeTools Web Site: <http://recipetools.gotdns.com/> http://recipetools.gotdns.com/
From: firstname.lastname@example.org [mailto:email@example.com] On Behalf Of Art Kocsis
Sent: Sunday, August 05, 2012 05:01
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:
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?
[Non-text portions of this message have been removed]