Regex (matchChunk) help...

Mike Bonner bonnmike at gmail.com
Fri Jun 15 21:09:26 EDT 2018


Hey cool!   I'd use Jims (an marks) method.  MUCH simpler.

On Fri, Jun 15, 2018 at 7:06 PM Jim Lambert via use-livecode <
use-livecode at lists.runrev.com> wrote:

> Building on what Mark Wieder elegantly wrote:
>
> > MarkW wrote:
> >
> >  filter lotsOfText with "*selkirkst*skyrider1*”
>
> function extractStrings lotsOfText, startWord, endWord
>
>         replace cr with space in lotsOfText -- Makes sure lotsOfText is
> just a single line
>
>         replace startWord with cr & startWord in lotsOfText -- Makes sure
> a line starts with the startWord
>
>         replace endWord with endWord & cr in lotsOfText -- Makes sure a
> line ends with the endWord
>
>         filter lotsOfText with "*" & startWord & "*" & endWord  — Mark’s
> suggestion
>
>         return lotsOfText
>
> end extractStrings
>
>
> Try it with your original gibberish. I‘ve added a second instance of the
> string you want to extract to show that the function will return all
> instances.
>
>
> Use the *selkirkst* function to check whether a *string* contains a
>
> specified pattern. If *selkirkst* includes a pair of parentheses, the
>
> position of the substring matching the part of theregular 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
>
> *selkirkst is
>
> placed in the second **skyrider1*. Additional starting and ending
>
> positions, matching additional parenthetical expressions, are placed in
>
> additional pairs of variables in thepositionVarsList. If the
>
> *selkirkst* function
>
> returns false, the values of the variables in the positionVarsListare not
>
> *selkirkst is
>
> placed in the third **skyrider1*. changed. The string and
> regularExpression are always case-sensitive,
>
> regardless of the setting of the caseSensitive property. (If you need to
>
> make a case-insensitive comparison, use "(?i)" at the start of the
>
> regularExpression to make the match case-insensitive.)
>
>
> Jim Lambert
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode



More information about the use-livecode mailing list