Regex (matchChunk) help...

Mike Bonner bonnmike at gmail.com
Fri Jun 15 12:36:02 EDT 2018


If I understand correctly.. If you find the beginning string occurrence,
and then find another beginning string, you want to ignore the first, and
only take strings where beginning and end have no intermediate beginnings?
Like this I mean..

beginning blah blah blah blah blah *beginning blah blah blah blah ending*

Where you would only want the bold part to match?

If so, it might be easiest to do a repeat for each trueword loop.

put 1 into tCounter
repeat for each trueword tword in tText
/*pseudocode
check the word. If its the beginning word, keep track of it using tCounter
so you know what word it was
If you're tracking a beginning and you hit a beginning again, track that
one instead.
If its the ending word, and you have a beginning word being tracked, place
the pair of word numbers into a list of found strings and reset the begin
tracker to empty
if its neither, do nothing
increment the counter
next loop
*/
end repeat

Of course if I've misunderstood what you need, kindly ignore this.

On Fri, Jun 15, 2018 at 10:27 AM Jerry Jensen via use-livecode <
use-livecode at lists.runrev.com> wrote:

> Will this do what you want? (untested)
>
> put empty into tExtract
> repeat for each line L in bigText
>   if char -9 to -1 of L is “skyrider1” then
>     if char 1 to 9 of L is “selkirkst” then
>       put L & return after tExtract
>     end if
>   end if
> end repeat
> if char -1 of tExtract is return then delete char -1 of tExtract
>
> > On Jun 15, 2018, at 8:45 AM, Glen Bojsza via use-livecode <
> use-livecode at lists.runrev.com> 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
>
>
> _______________________________________________
> 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