Search / replace
J. Landman Gay
jacque at hyperactivesw.com
Sat Feb 20 02:17:37 CST 2010
Glen Bojsza wrote:
> Sorry to bother everyone but either I'm tired or brain dead.
> I have a field which has hundreds of lines.
> For all [ in the field I need to check to see if the character to it's
> immediate left is a number.
> If it is a number then the [ is to be converted into an _.
> If it is not a number then the [ is to be removed (no substitution or
> I need to be able to cycle through the entire field which each line may
> contain several [.
> Any thoughts would be appreciated as I have tried using a combination of
> find characters and foundchunk on the field without success.
This sounds like a perfect job for the replacetext command; regular
expressions are ideal for this kind of problem. You won't need any
loops, though you may need to run it twice, once to get all the brackets
followed by numbers, and a second time to remove the single brackets. If
Alex or Ken or someone else doesn't step in first, I'll see if I can get
the regex worked up for you tomorrow. Maybe someone even knows how to
test for both situations and replacements in the same expression. I know
there's a way to do that but I'm not sure how.
At any rate, once you get the right regex figured out, it's a one-liner
to do what you want.
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
More information about the use-livecode