Regex (matchChunk) help...

Brian Milby brian at milby7.com
Fri Jun 15 12:38:48 EDT 2018


I’m a little confused about the requirements. Can the desired text span lines? If not, it changes things slightly.

Offset is something you can use. Find location of end token. Find location of first start token. Find location of next start token. If before end token, try again until after or none. Then you have the bounds for the first match. I’ll try to write up code to test later this evening if no one provides a good example before then. Offset has a param for chars to skip.
On Jun 15, 2018, 10:46 AM -0500, Glen Bojsza via use-livecode , wrote:
> Hello,
>
> I have a couple of hundred pages of text where I need to extract out a
> different string.
>
> The ending of each string I need has the same ending skyrider1
>
> The beginning of each string is the same selkirkst
>
> The middle of each string can be any text.
>
> The problem is that within each line where a string exists there are
> several strings that have the same beginning selkirkst but none of the have
> the correct ending skyrider1.
>
> My thoughts are to find ending of the string first and then work backwards
> to the first beginning string.
>
> I created the following example which is gibberish but should make this
> clearer... this is the string I want to extract from the line given is
> *selkirkst is
> placed in the second **skyrider1*
>
>
>
> 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
> 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.)
>
> The next line will not have *is placed in the second* but some other text
> *selkirkst* ???? *skyrider1*
>
> I am not sure if this explains it well enough but I believe a regex
> expression could be used (or perhaps a matchChunk) to extract the correct
> string from each line of text.
>
> Any suggestions?
>
> thanks,
>
> Glen
> _______________________________________________
> 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