Hi Terry, Maybe the 'matchChunk' function can help you achieve your goal? >From its dictionary entry: #### Syntax: matchChunk(string,regularExpression[,positionVarsList]) ... If the regularExpression includes a pair of parentheses, the position of the substring matching the part of the regular expression inside the parentheses is placed in the variables in the positionVarsList. The number of the first character in the matching substring is placed in the first variable in the positionVarsList, and the number of the last character is placed in the second variable. Additional starting and ending positions, matching additional parenthetical expressions, are placed in additional pairs of variables in the positionVarsList. If the matchChunk function returns false, the values of the variables in the positionVarsList are not changed. ####
So if matchText(...) returns true, and you've provided enough start and end match variables, you can iterate backwards over those match position pairs to insert the replacement text. Or maybe I haven't completely grasped what you were trying to accomplish - it's been a long day. Jan Schenkel. ===== Quartam Reports & PDF Library for LiveCode www.quartam.com ===== "As we grow older, we grow both wiser and more foolish at the same time." (La Rochefoucauld) ----- Original Message ----- > From: Terry Vogelaar <tvogel...@de-mare.nl> > To: How to use LiveCode <use-livecode@lists.runrev.com> > Cc: > Sent: Tuesday, July 2, 2013 1:19 PM > Subject: Regular expressions > >G REP saved my bacon in several occasions. And the regular expressions in LC >are > somewhat similar to GREP, but not quite. > > In GREP I can do this: > > stringToChange: <body><span>Block of text</span></body> > matchExpression: <span>[^<]+</span> > replacementString: <div>?</div> > result: <body><div><span>Block of > text</span></div></body> > > The question-mark fills in everything that matches the matchExpression. Very > useful when you want to put something around the found instances. > > Or you can even take it a step further by using ( and ) in combination with > \1, \2 etc.: > > stringToChange: <body><span class="MakeMeVisible">Block of > text</span></body> > matchExpression: <span > class="([^"]+)">([^<]+)</span> > replacementString: <span>\1: \2</span> > result: <body><span>MakeMeVisible: Block of > text</span></body> > > The \1 fills in what it found inside the first pair of parentheses; the > \2 the second pair. This way you can do really powerful replacements, if you > know what you are doing. > > So I wonder how I do this in LC. I know I need to use Perlre and not GREP. So > how do I do this in Perlre? > > Terry > _______________________________________________ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your subscription > preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode > _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode