Regex help...

Mike Bonner bonnmike at gmail.com
Mon Jun 5 09:05:53 EDT 2017


Wow, the perl way is pretty darn cool.

On Mon, Jun 5, 2017 at 2:06 AM, Thierry Douez via use-livecode <
use-livecode at lists.runrev.com> wrote:

> Hi Paul,
>
>
> AFAIK you need to deal with an hybrid approach (regex + livecode)
>
> So, here is one way to do it:
>
>
>    put 3 into pPage
>
>    repeat for each line T in tCiCData
>
>       if matchText( T, "(?x) \t (\d+) , \d+ ,  (\d+)  , \d+ \z", n1, n2)
> then
>
>       if (n1 <= pPage) and (n2 >= pPage) then
>
>           put T & cr after tCiCfilteredData
>
>       end if
>
>       end if
>
>    end repeat
>
>    put tCiCfilteredData
>
>
> But for the curious with an open-mind here is another solution:
>
>
>    get "perl -ne 'print if /\t(\d+),\d+,(\d+),\d+$(?(?{$1>PP ||
> $2<PP})(*FAIL))/'"
>
>    get replaceText( IT, "PP", pPage)
>
>    put shell( IT && "/your/path/CiCData.txt")
>
>
> What? the regex do the comparison!
> Well yes and no; in Perl we can embed Perl code *inside* the regex,
> like: (?{$1>PP || $2<PP})
>
> $1>PP || $2<PP is a Perl expression.
>
> As we have a mixture of a regex pattern and some perl code;
> that is in fact another hybrid solution.
>
>
> And of course, you can do it  using only chunks , item and so on...
>
>
> Have fun,
>
> Thierry
>
>
>
>
> 2017-06-04 17:35 GMT+02:00 Paul Dupuis via use-livecode <
> use-livecode at lists.runrev.com>:
>
> > I have a tab and cr delimited table of data, a sample line of which is
> > below:
> >
> > 1<tab>Test<tab>4052,12594<tab>1,4052,3,2388<cr>
> >
> > Can someone help me revise this regex to match what I need?
> >
> > Thank you kindly, in advance.
> >
>
> --
> ------------------------------------------------
> Thierry Douez - sunny-tdz.com
> sunnYrex - sunnYtext2speech - sunnYperl - sunnYmidi - sunnYmage
> _______________________________________________
> 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