AW: Re: Regex help needed...

Paul Dupuis paul at researchware.com
Sat Jan 30 16:49:12 EST 2016


Never mind. Solved it.

It was the pattern for the 2nd format. Fixed with
"(.+\t"&pPage&",\d+,\d+,\d+)|(.+\t\d+,\d+,"&pPage&",\d+)|(.+\t"&pPage&",\d*\.?\d*,\d*\.?\d*,\d*\.?\d*,\d*\.?\d*)"

On 1/30/2016 3:17 PM, Paul Dupuis wrote:
> I need some regex help.
>
> I have a list that is of the form:
> <number><tab><text><tab><numberCol1><tab><numberCol2>
> i.e.
> 1    Testing    1,747    1,1,1,747
> 2    Testing    752,1800    1,752,1,1800
> 3    Testing    5398,5846    2,320,2,768
> 4    Testing    3,111.951,683.915,302.268,385.751  
>  3,111.951,683.915,302.268,385.751
>
> <numberCol2> can have a list of number in 1 of 2 formats:
> A comma separated list of 4 integers, i.e.
> <integer1>,<integer2>,<integer3>,<integer4>
> OR
> A comma separated list of 1 integer, followed by 4 decimal numbers, i.e.
> <integer>,<decimal>,<decimal>,<decimal>,<decimal>
>
> I need filter the lines of this list with a REGEX pattern to get lines
> WHERE a value pPage matches certain places in <numberCol2>, specifically:
> where pPage is equal to either <integer1> or <integer3> in the first
> format(i.e. item 1 or item 3)
> OR
> where pPage is equal to <integer> in the second format(i.e. item 1)
>
> So my code is:
> put
> "((.+\t"&pPage&",\d+,\d+,\d+)|(.+\t\d+,\d+,"&pPage&",\d+)|(.+\t"&pPage&",?[0-9]*\.?[0-9]+,?[0-9]*\.?[0-9]+,?[0-9]*\.?[0-9]+,?[0-9]*\.?[0-9]+))"
> into tMatchPattern
> filter lines of tList with regex pattern tMatchPattern
>  
> If pPage is 1 then I should get:
> 1    Testing    1,747    1,1,1,747
> 2    Testing    752,1800    1,752,1,1800
> and I do. If pPage is 2 then I should get:
> 3    Testing    5398,5846    2,320,2,768
> and I do. If pPage is 3 then I should get:
> 4    Testing    3,111.951,683.915,302.268,385.751  
>  3,111.951,683.915,302.268,385.751
> and I do. if pPage is 4 then I should get and empty list, and I do, but
> when pPage is 5, I am expecting an empty list and I get
> 3    Testing    5398,5846    2,320,2,768
>
> So something is wrong with my Regex, but I can not figure out what? It
> looks like it is matching against <numberCol1> in the last case
> (pPage=5) but it should not since there are only 2 items in the list
> rather than 4 or 5.
>
> I am using LiveCode 6.7.6
>
>
> _______________________________________________
> 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