Re: Regex help...
On Sun, Jun 4, 2017 at 1:45 PM, hh via use-livecode < use-livecode@lists.runrev.com> wrote: > Your "ie" is not true. So what do you want? Regexp is red, my face turneth blue. My heart is now shattered, For my "ie" ie is untrue. :) -- Dr. Richard E. Hawkins, Esq. (702) 508-8462 ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Regex help...
If the number of comma-delimited and tab-delimited elements is always the same, I would replace all commas with tabs and then filter to have item x having value of y. Robert On 5 Jun 2017, at 15:23, Paul Dupuis via use-livecode wrote: Thank you Thierry and everyone else. I should have realized that I couldn't do this entirely with regex due to the need to compare the number values. It was a long day yesterday and my brain just wasn't in full gear. -- Paul ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Regex help...
@Paul, to defend you, it's not always so obvious to know what we can or cannot do with regex. @Mike yes, Perl is great and that's certainly why I have embeded Perl in LiveCode, Mmm, more than 10 years ago. I've also helped some well known LiveCoders to do some complex transformation with Perl where they were lost in pure LiveCode script; but this is another story. By the way, there is a not free LiveCode library called sunnYrex which accepts LiveCode script inside the replacement text.. pretty cool too but not useful in Paul use case. Kind regards, Thierry 2017-06-05 15:23 GMT+02:00 Paul Dupuis via use-livecode < use-livecode@lists.runrev.com>: > Thank you Thierry and everyone else. > > I should have realized that I couldn't do this entirely with regex due > to the need to compare the number values. It was a long day yesterday > and my brain just wasn't in full gear. > > -- Paul > > > On 6/5/2017 4:06 AM, Thierry Douez via use-livecode 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 > > >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 > > > $1>PP || $2 > > > 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@lists.runrev.com>: > > > >> I have a tab and cr delimited table of data, a sample line of which is > >> below: > >> > >> 1Test4052,125941,4052,3,2388 > >> > >> 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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
AW: Regex help...
Thank you Thierry and everyone else. I should have realized that I couldn't do this entirely with regex due to the need to compare the number values. It was a long day yesterday and my brain just wasn't in full gear. -- Paul On 6/5/2017 4:06 AM, Thierry Douez via use-livecode 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 >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 > $1>PP || $2 > 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@lists.runrev.com>: > >> I have a tab and cr delimited table of data, a sample line of which is >> below: >> >> 1Test4052,125941,4052,3,2388 >> >> Can someone help me revise this regex to match what I need? >> >> Thank you kindly, in advance. >> ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Regex help...
Wow, the perl way is pretty darn cool. On Mon, Jun 5, 2017 at 2:06 AM, Thierry Douez via use-livecode < use-livecode@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 >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 > $1>PP || $2 > 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@lists.runrev.com>: > > > I have a tab and cr delimited table of data, a sample line of which is > > below: > > > > 1Test4052,125941,4052,3,2388 > > > > 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@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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Regex help...
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 || $2PP || $2PP || $2: > I have a tab and cr delimited table of data, a sample line of which is > below: > > 1Test4052,125941,4052,3,2388 > > 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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Regex help...
When I'm fighting a regex, I go to http://pythex.org/ On Sun, Jun 4, 2017 at 2:11 PM, Mike Bonner via use-livecode < use-livecode@lists.runrev.com> wrote: > Not sure regex can do what you want, or if it can its far far over my > head. Would it work instead to use lc script to parse? > If you repeat through your data (each line form, with tLine as the current > line and pPage as the page to be looked for...) you can use a one liner > like this to build a list of matching lines, chop the trailing cr > afterwards, and be done with it. > > *if* item -2 of tLine >= pPage and item -4 of tLine <= pPage *then* *put* > tLine & cr after tNewDat > > > On Sun, Jun 4, 2017 at 9:35 AM, Paul Dupuis via use-livecode < > use-livecode@lists.runrev.com> wrote: > > > I have a tab and cr delimited table of data, a sample line of which is > > below: > > > > 1Test4052,125941,4052,3,2388 > > > > The last tab delimited item "1,4052,3,2388" is actually > Number>,,, > Position On Page> > > > > So the starting page number is 1 and ending page is 3 > > > > I have a variable pPage which contain a page number, say "2" > > > > My regex filter, that was crafted by someone else, needs to find (filter > > to just) all lines starting on page 2 OR ending on page 2 OR containing > > page 2 (ie, pPage is >= starting page and <= ending page) > > > > My existing filter, below, matched lines with starting page number and > > ending page numbers but not line with page numbers between the start and > > end. > > > > put > > "(.+\t"&pPage&",\d+,\d+,\d+)|(.+\t\d+,\d+,"&pPage&",\d+)|(.+ > > \t"&pPage&",\d*\.?\d*,\d*\.?\d*,\d*\.?\d*,\d*\.?\d*)" > > into tMatchPattern > > filter lines of tCiCData with regex pattern tMatchPattern > > > > Can someone help me revise this regex to match what I need? > > > > Thank you kindly, in advance. > > > > > > > > ___ > > use-livecode mailing list > > use-livecode@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@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your > subscription preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode > -- On the first day, God created the heavens and the Earth On the second day, God created the oceans. On the third day, God put the animals on hold for a few hours, and did a little diving. And God said, "This is good." ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Regex help...
Forget it. I'm wrong, it's too late. Sorry. > hh wrote: > [a] all lines starting on page 2 OR ending on page 2 OR containing page 2 > ie > (pPage >= starting page) OR (pPage <= ending page) > > [b] all lines starting on page 2 AND ending on page 2 > ie > (pPage >= starting page) AND (pPage <= ending page) ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Regex help...
Your "ie" is not true. So what do you want? [a] all lines starting on page 2 OR ending on page 2 OR containing page 2 ie (pPage >= starting page) OR (pPage <= ending page) [b] all lines starting on page 2 AND ending on page 2 ie (pPage >= starting page) AND (pPage <= ending page) > Paul D. wrote: > My regex filter, that was crafted by someone else, needs to find (filter to > just) all lines starting on page 2 OR ending on page 2 OR containing page 2 > (ie, pPage is >= starting page and <= ending page) ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Regex help...
Not sure regex can do what you want, or if it can its far far over my head. Would it work instead to use lc script to parse? If you repeat through your data (each line form, with tLine as the current line and pPage as the page to be looked for...) you can use a one liner like this to build a list of matching lines, chop the trailing cr afterwards, and be done with it. *if* item -2 of tLine >= pPage and item -4 of tLine <= pPage *then* *put* tLine & cr after tNewDat On Sun, Jun 4, 2017 at 9:35 AM, Paul Dupuis via use-livecode < use-livecode@lists.runrev.com> wrote: > I have a tab and cr delimited table of data, a sample line of which is > below: > > 1Test4052,125941,4052,3,2388 > > The last tab delimited item "1,4052,3,2388" is actually Number>,,, Position On Page> > > So the starting page number is 1 and ending page is 3 > > I have a variable pPage which contain a page number, say "2" > > My regex filter, that was crafted by someone else, needs to find (filter > to just) all lines starting on page 2 OR ending on page 2 OR containing > page 2 (ie, pPage is >= starting page and <= ending page) > > My existing filter, below, matched lines with starting page number and > ending page numbers but not line with page numbers between the start and > end. > > put > "(.+\t"&pPage&",\d+,\d+,\d+)|(.+\t\d+,\d+,"&pPage&",\d+)|(.+ > \t"&pPage&",\d*\.?\d*,\d*\.?\d*,\d*\.?\d*,\d*\.?\d*)" > into tMatchPattern > filter lines of tCiCData with regex pattern tMatchPattern > > Can someone help me revise this regex to match what I need? > > Thank you kindly, in advance. > > > > ___ > use-livecode mailing list > use-livecode@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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Regex help...
I have a tab and cr delimited table of data, a sample line of which is below: 1Test4052,125941,4052,3,2388 The last tab delimited item "1,4052,3,2388" is actually ,,, So the starting page number is 1 and ending page is 3 I have a variable pPage which contain a page number, say "2" My regex filter, that was crafted by someone else, needs to find (filter to just) all lines starting on page 2 OR ending on page 2 OR containing page 2 (ie, pPage is >= starting page and <= ending page) My existing filter, below, matched lines with starting page number and ending page numbers but not line with page numbers between the start and end. put "(.+\t"&pPage&",\d+,\d+,\d+)|(.+\t\d+,\d+,"&pPage&",\d+)|(.+\t"&pPage&",\d*\.?\d*,\d*\.?\d*,\d*\.?\d*,\d*\.?\d*)" into tMatchPattern filter lines of tCiCData with regex pattern tMatchPattern Can someone help me revise this regex to match what I need? Thank you kindly, in advance. ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: AW: Re: Regex help needed...
Hi Thierry, I might have missed it but did you publish your Regex2 to the list? Pete On Wed, Feb 3, 2016 at 12:07 PM Richard Gaskin wrote: > Thierry Douez write: > > >> Regex has been around a long time > >> and lots of smart computer science types has > >> spent time coming up with ways to optimize its performance for pattern > >> matching. > > > > That's was true, it's still true and will always be true! > > It's true that there are almost always ways to improve performance using > any method, but there are times when one method may be faster than > another so it's worth testing out, as you did here: > > > and here are some benchmarks > > done in a late rainy sunday evening: > > > > > > * Regex2 faster than Chunk by: 2.1 times* > > Great results - what was the regex you used for that? > > > > For the details: > > > > 1) Regex1 is the original regex, Chunk1 is from Richard, Regex2 is mine. > > 2) You can noticed the difference in time depending on the value of pPage > > ( that's a normal behavior with regex) > > 3) I've done the calculation the same way as Richard did, so you can > compare > > > > > > > > ** aPage = 1, Same? true true > > Regex1: 8943 ms > > Chunk1: 210 ms > > Regex2: 99 ms > > Regex2 faster than orig regex by: 90.3 times > > Regex2 faster than Chunk by: 2.1 times > > > > ** aPage = 2, Same? true true > > Regex1: 9946 ms > > Chunk1: 212 ms > > Regex2: 100 ms > > Regex2 faster than orig regex by: 99.5 times > > Regex2 faster than Chunk by: 2.1 times > > > > ** aPage = 3, Same? true true > > Regex1: 4451 ms > > Chunk1: 210 ms > > Regex2: 98 ms > > Regex2 faster than orig regex by: 45.4 times > > Regex2 faster than Chunk by: 2.1 times > > > > ** aPage = 4, Same? true true > > Regex1: 11465 ms > > Chunk1: 200 ms > > Regex2: 98 ms > > Regex2 faster than orig regex by: 117 times > > Regex2 faster than Chunk by: 2 times > > > > ** aPage = 5, Same? true true > > Regex1: 11457 ms > > Chunk1: 201 ms > > Regex2: 94 ms > > Regex2 faster than orig regex by: 121.9 times > > Regex2 faster than Chunk by: 2.1 times > > > > -- > Richard Gaskin > Fourth World Systems > Software Design and Development for the Desktop, Mobile, and the Web > > ambassa...@fourthworld.comhttp://www.FourthWorld.com > > ___ > use-livecode mailing list > use-livecode@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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: AW: Re: Regex help needed...
Thierry Douez write: Regex has been around a long time and lots of smart computer science types has spent time coming up with ways to optimize its performance for pattern matching. That's was true, it's still true and will always be true! It's true that there are almost always ways to improve performance using any method, but there are times when one method may be faster than another so it's worth testing out, as you did here: and here are some benchmarks done in a late rainy sunday evening: * Regex2 faster than Chunk by: 2.1 times* Great results - what was the regex you used for that? For the details: 1) Regex1 is the original regex, Chunk1 is from Richard, Regex2 is mine. 2) You can noticed the difference in time depending on the value of pPage ( that's a normal behavior with regex) 3) I've done the calculation the same way as Richard did, so you can compare ** aPage = 1, Same? true true Regex1: 8943 ms Chunk1: 210 ms Regex2: 99 ms Regex2 faster than orig regex by: 90.3 times Regex2 faster than Chunk by: 2.1 times ** aPage = 2, Same? true true Regex1: 9946 ms Chunk1: 212 ms Regex2: 100 ms Regex2 faster than orig regex by: 99.5 times Regex2 faster than Chunk by: 2.1 times ** aPage = 3, Same? true true Regex1: 4451 ms Chunk1: 210 ms Regex2: 98 ms Regex2 faster than orig regex by: 45.4 times Regex2 faster than Chunk by: 2.1 times ** aPage = 4, Same? true true Regex1: 11465 ms Chunk1: 200 ms Regex2: 98 ms Regex2 faster than orig regex by: 117 times Regex2 faster than Chunk by: 2 times ** aPage = 5, Same? true true Regex1: 11457 ms Chunk1: 201 ms Regex2: 94 ms Regex2 faster than orig regex by: 121.9 times Regex2 faster than Chunk by: 2.1 times -- Richard Gaskin Fourth World Systems Software Design and Development for the Desktop, Mobile, and the Web ambassa...@fourthworld.comhttp://www.FourthWorld.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: AW: Re: Regex help needed...
On Wed, Feb 3, 2016 at 11:53 AM Bernard Devlin wrote: > One of the things we had in LC5 which was phenomenally fast, was searching > through the styledText of a field. That fast way of searching particular > text structures got lost in the migration to LC8. Could you expand on this a little? I'm not sure exactly what you mean by 'searching through the styledText of a field'. Thanks, Ali ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: AW: Re: Regex help needed...
There's huge differences in how regex implementations perform in different > languages. For example: http://raid6.com.au/~onlyjob/posts/arena/ > Last year, I did some experiments: I had a 100 lines of LiveCode with a bunch of really big Regex. It took 120 seconds on my Macbook to run. I tried diffferent ways to write/modify the regex, and it always keep running around 120 seconds. Then, using my sunnYperl external, I copy/paste all my regex ( not one modification ) and rewrite the LC part in Perl (a bit more work but not that much). I came down to 9 seconds. Kind regards, Thierry -- Thierry Douez - http://sunny-tdz.com sunnYrex - sunnYtext2speech - sunnYperl - sunnYmidi - sunnYmage ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: AW: Re: Regex help needed...
On 03/02/2016 11:53, Bernard Devlin wrote: Perl outperforms everything in that test. I've never assumed that LC's "perl compatiable regex library" is going to perform at the speed which actual Perl performs. I've always assumed that being "perl compatible" just meant that all syntactically-correct Perl regexs should run with LC's implementation, without needing any kind of change in how the regex is formatted. To be precise, LiveCode uses the PCRE library, which is generally considered to be the *definitive* implementation of Perl Compatible Regular Expressions: http://www.pcre.org/. There isn't a special LiveCode-specific implementation of regular expressions involved. Peter -- Dr Peter Brett LiveCode Open Source Team LiveCode on reddit: https://reddit.com/r/livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: AW: Re: Regex help needed...
Hi Mark, There's huge differences in how regex implementations perform in different languages. For example: http://raid6.com.au/~onlyjob/posts/arena/ Perl outperforms everything in that test. I've never assumed that LC's "perl compatiable regex library" is going to perform at the speed which actual Perl performs. I've always assumed that being "perl compatible" just meant that all syntactically-correct Perl regexs should run with LC's implementation, without needing any kind of change in how the regex is formatted. There was an academic paper I came across 15 years ago, which showed that Tcl out-performed Perl. Now it seems Perl outperforms Tcl, suggesting that one or the other has made changes to their underlying engine which impact regex performance. Or that the tests I read about 15 years ago were just testing regex features which resulted in Tcl out-performing Perl, and vice-versa in the above test. It would be great if LC's implementation was as fast as Perl's. Here's a page comparing several implementations of PCRE (with some non-pcre regex implementations): http://sljit.sourceforge.net/regex_perf.html One of the things we had in LC5 which was phenomenally fast, was searching through the styledText of a field. That fast way of searching particular text structures got lost in the migration to LC8. Regards Bernard ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: AW: Re: Regex help needed...
> Regex has been around a long time > and lots of smart computer science types has > spent time coming up with ways to optimize its performance for pattern > matching. That's was true, it's still true and will always be true! and here are some benchmarks done in a late rainy sunday evening: * Regex2 faster than Chunk by: 2.1 times* For the details: 1) Regex1 is the original regex, Chunk1 is from Richard, Regex2 is mine. 2) You can noticed the difference in time depending on the value of pPage ( that's a normal behavior with regex) 3) I've done the calculation the same way as Richard did, so you can compare ** aPage = 1, Same? true true Regex1: 8943 ms Chunk1: 210 ms Regex2: 99 ms Regex2 faster than orig regex by: 90.3 times Regex2 faster than Chunk by: 2.1 times ** aPage = 2, Same? true true Regex1: 9946 ms Chunk1: 212 ms Regex2: 100 ms Regex2 faster than orig regex by: 99.5 times Regex2 faster than Chunk by: 2.1 times ** aPage = 3, Same? true true Regex1: 4451 ms Chunk1: 210 ms Regex2: 98 ms Regex2 faster than orig regex by: 45.4 times Regex2 faster than Chunk by: 2.1 times ** aPage = 4, Same? true true Regex1: 11465 ms Chunk1: 200 ms Regex2: 98 ms Regex2 faster than orig regex by: 117 times Regex2 faster than Chunk by: 2 times ** aPage = 5, Same? true true Regex1: 11457 ms Chunk1: 201 ms Regex2: 94 ms Regex2 faster than orig regex by: 121.9 times Regex2 faster than Chunk by: 2.1 times Kind regards, Thierry Thierry Douez - http://sunny-tdz.com sunnYrex - sunnYtext2speech - sunnYperl - sunnYmidi - sunnYmage ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: AW: Re: Regex help needed...
Paul Dupuis wrote: > Wow. I would not have expected such a significant difference. Regex > has been around a long time and lots of smart computer science types > has spent time coming up with ways to optimize its performance for > pattern matching. I assumed (falsely) that regex based filters in LC > would be on par or even superior than a custom function using chunks. > This leads me to: > > 1) wondering if LC's hooks to whatever regex tool they are using under > the hood is a good as it should be > AND > 2) planning on rewriting my code to use chunks. One of the reasons for my seemingly-obsessive benchmarking is to learn about what goes on under the hood, and to try to anticipate it when choosing among different algos. LC does such a good job of shielding us from what goes on under the hood that we often forget that the relationship between the number of lines we write and the number of machine instructions our scripts invoke may differ broadly depending on the statement. My favorite example is: set the scroll of field 1 to 100 -- seems simple enough, but having written scrollbar management routines in C back in the pre-Cocoa days I learned that a *tremendous* number of low-level routines come into play with that one simple line of script. LC makes it easy to take this stuff for granted, since it does all the heavy lifting. Same with regex. The beauty of regex is that it's a very generalized solution. The downside of regex is that it's a very generalized solution. ;) Generalized options can provide convenience, but often at the cost of performance. Purpose-built solutions are usually much faster than generalized ones, and with LC's chunk expressions they're fun to write too. :) There are times when regex will outperform chunk expressions, though, so I would caution against rewriting everything. Benchmarking is the key, and some day I will have done enough to be able to come up with a small set of useful rules as to when to use chunks and when to use regex. But at the moment, it's half hunch and half benchmarking to confirm the hunch. -- Richard Gaskin Fourth World Systems Software Design and Development for the Desktop, Mobile, and the Web ambassa...@fourthworld.comhttp://www.FourthWorld.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: AW: Re: Regex help needed...
On 01/30/2016 04:28 PM, Paul Dupuis wrote: 1) wondering if LC's hooks to whatever regex tool they are using under the hood is a good as it should be LC's regex library is the same PCRE library everyone else uses. And it's the latest released version. Regex's power lies in its ability to match complex patterns, which doesn't necessarily translate to speed. AND 2) planning on rewriting my code to use chunks. You may find that regex matching works better than LC's chunk matching in some situations. For speed though, it's hard to beat the built=in chunking functions in LC, as they're already pretty well optimized. -- Mark Wieder ahsoftw...@gmail.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: AW: Re: Regex help needed...
Wow. I would not have expected such a significant difference. Regex has been around a long time and lots of smart computer science types has spent time coming up with ways to optimize its performance for pattern matching. I assumed (falsely) that regex based filters in LC would be on par or even superior than a custom function using chunks. This leads me to: 1) wondering if LC's hooks to whatever regex tool they are using under the hood is a good as it should be AND 2) planning on rewriting my code to use chunks. Thanks for the post. On 1/30/2016 6:45 PM, Richard Gaskin wrote: > Regex is wonderfully compact to write relative to equivalent routines > using chunk expressions, but sometimes paid for in execution time. > > When I come across a good regex example like the one you provided, if > I have a moment I like to test things out to see where regex is faster > and where it isn't. It's really great for many things, but carries > quite a bit of overhead. > > Of course for this test to be relevant it assumes that most of the > specifiers in the regex expression are merely to identify the elements > you're looking for, and that the data is expected to fit the > definition you provided. > > Given that, it's possible to make the regex a bit simpler (see foo2 > below), but only with a modest boost to performance. It can probably > be simplified more, but the chunk-based alternative performed so well > I didn't bother exploring the regex side any further. > > Writing a lengthier handler that uses chunk expressions seems to yield > the same results you reported, running between 12 and 60 times faster > (depending on the percentage of lines tested that match the criteria > being looked for). > > For one-offs like validating email addresses regex can be an excellent > fit, and even some larger tasks depending on the specifics. > > But for iterating across lists I've often been delightfully surprised > by LiveCode's gracefully efficient chunk handling. > > Testing your original data replicated to become 250 lines long, and > looking for page 1 among them, the script below yields: > > Regex: 9261 ms > RegexLite: 7958 ms > Chunks: 197 ms > Chunks faster than orig regex by: 47.01 times > Chunks faster than lite regex by: 40.4 times > Same result? true > > > on mouseUp > put fld 1 into tList > put 1 into tPage --< change this for different tests > put 1000 into n > -- > -- Test 1: original regex > put the millisecs into t > repeat n > put foo1(tPage, tList) into r1 > end repeat > put the millisecs - t into t1 > -- > -- Test 2: lighter regex > put the millisecs into t > repeat n > put foo2(tPage, tList) into r2 > end repeat > put the millisecs - t into t2 > -- > -- Test 3: chunks > put the millisecs into t > repeat n > put foo3(tPage, tList) into r3 > end repeat > put the millisecs - t into t3 > -- > -- Display results: > set the numberformat to "0.##" > put "Regex: "&t1 &" ms"&cr \ > &"RegexLite: "&t2 &" ms"&cr \ > &"Chunks: "& t3 &" ms"&cr \ > &"Chunks faster than orig regex by: "&(t1 / t3)&" times" &cr \ > &"Chunks faster than lite regex by: "&(t2 / t3)&" times" &cr \ > &"Same result? "& (r1=r3) &cr&cr& r1 &cr&cr& r3 > end mouseUp > > > function foo1 pPage, tList > put > "(.+\t"&pPage&",\d+,\d+,\d+)|(.+\t\d+,\d+,"&pPage&",\d+)|(.+\t"&pPage&",\d*\.?\d*,\d*\.?\d*,\d*\.?\d*,\d*\.?\d*)" > into tMatchPattern > filter lines of tList with regex pattern tMatchPattern > return tList > end foo1 > > > function foo2 pPage, tList > put "(.+\t"&pPage&",*)|(.+\t\d+,\d+,"&pPage&",*)|(.+\t"&pPage&",*)" > into tMatchPattern > filter lines of tList with regex pattern tMatchPattern > return tList > end foo2 > > > > function foo3 pPage, tList > repeat for each line tLine in tList > set the itemdel to tab > put item 3 of tLine into t1 > put pPage &"," into tPageMarker > if "." is in t1 then > if (t1 begins with tPageMarker) then > put tLine &cr after tNuList > end if > else > if ( t1 begins with tPageMarker) OR (item 4 of tLine begins with > tPageMarker) then > put tLine &cr after tNuList > end if > end if > end repeat > delete last char of tNuList > return tNuList > end foo3 > > > > > > > > > > ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: AW: Re: Regex help needed...
Regex is wonderfully compact to write relative to equivalent routines using chunk expressions, but sometimes paid for in execution time. When I come across a good regex example like the one you provided, if I have a moment I like to test things out to see where regex is faster and where it isn't. It's really great for many things, but carries quite a bit of overhead. Of course for this test to be relevant it assumes that most of the specifiers in the regex expression are merely to identify the elements you're looking for, and that the data is expected to fit the definition you provided. Given that, it's possible to make the regex a bit simpler (see foo2 below), but only with a modest boost to performance. It can probably be simplified more, but the chunk-based alternative performed so well I didn't bother exploring the regex side any further. Writing a lengthier handler that uses chunk expressions seems to yield the same results you reported, running between 12 and 60 times faster (depending on the percentage of lines tested that match the criteria being looked for). For one-offs like validating email addresses regex can be an excellent fit, and even some larger tasks depending on the specifics. But for iterating across lists I've often been delightfully surprised by LiveCode's gracefully efficient chunk handling. Testing your original data replicated to become 250 lines long, and looking for page 1 among them, the script below yields: Regex: 9261 ms RegexLite: 7958 ms Chunks: 197 ms Chunks faster than orig regex by: 47.01 times Chunks faster than lite regex by: 40.4 times Same result? true on mouseUp put fld 1 into tList put 1 into tPage --< change this for different tests put 1000 into n -- -- Test 1: original regex put the millisecs into t repeat n put foo1(tPage, tList) into r1 end repeat put the millisecs - t into t1 -- -- Test 2: lighter regex put the millisecs into t repeat n put foo2(tPage, tList) into r2 end repeat put the millisecs - t into t2 -- -- Test 3: chunks put the millisecs into t repeat n put foo3(tPage, tList) into r3 end repeat put the millisecs - t into t3 -- -- Display results: set the numberformat to "0.##" put "Regex: "&t1 &" ms"&cr \ &"RegexLite: "&t2 &" ms"&cr \ &"Chunks: "& t3 &" ms"&cr \ &"Chunks faster than orig regex by: "&(t1 / t3)&" times" &cr \ &"Chunks faster than lite regex by: "&(t2 / t3)&" times" &cr \ &"Same result? "& (r1=r3) &cr&cr& r1 &cr&cr& r3 end mouseUp function foo1 pPage, tList put "(.+\t"&pPage&",\d+,\d+,\d+)|(.+\t\d+,\d+,"&pPage&",\d+)|(.+\t"&pPage&",\d*\.?\d*,\d*\.?\d*,\d*\.?\d*,\d*\.?\d*)" into tMatchPattern filter lines of tList with regex pattern tMatchPattern return tList end foo1 function foo2 pPage, tList put "(.+\t"&pPage&",*)|(.+\t\d+,\d+,"&pPage&",*)|(.+\t"&pPage&",*)" into tMatchPattern filter lines of tList with regex pattern tMatchPattern return tList end foo2 function foo3 pPage, tList repeat for each line tLine in tList set the itemdel to tab put item 3 of tLine into t1 put pPage &"," into tPageMarker if "." is in t1 then if (t1 begins with tPageMarker) then put tLine &cr after tNuList end if else if ( t1 begins with tPageMarker) OR (item 4 of tLine begins with tPageMarker) then put tLine &cr after tNuList end if end if end repeat delete last char of tNuList return tNuList end foo3 -- Richard Gaskin Fourth World Systems Software Design and Development for the Desktop, Mobile, and the Web ambassa...@fourthworld.comhttp://www.FourthWorld.com Paul Dupuis wrote: 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: i.e. 1Testing1,7471,1,1,747 2Testing752,18001,752,1,1800 3Testing5398,58462,320,2,768 4Testing3,111.951,683.915,302.268,385.751 3,111.951,683.915,302.268,385.751 can have a list of number in 1 of 2 formats: A comma separated list of 4 integers, i.e. ,,, OR A comma separated list of 1 integer, followed by 4 decimal numbers, i.e. I need
AW: Re: Regex help needed...
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: > > i.e. > 1Testing1,7471,1,1,747 > 2Testing752,18001,752,1,1800 > 3Testing5398,58462,320,2,768 > 4Testing3,111.951,683.915,302.268,385.751 > 3,111.951,683.915,302.268,385.751 > > can have a list of number in 1 of 2 formats: > A comma separated list of 4 integers, i.e. > ,,, > OR > A comma separated list of 1 integer, followed by 4 decimal numbers, i.e. > > > I need filter the lines of this list with a REGEX pattern to get lines > WHERE a value pPage matches certain places in , specifically: > where pPage is equal to either or in the first > format(i.e. item 1 or item 3) > OR > where pPage is equal to 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: > 1Testing1,7471,1,1,747 > 2Testing752,18001,752,1,1800 > and I do. If pPage is 2 then I should get: > 3Testing5398,58462,320,2,768 > and I do. If pPage is 3 then I should get: > 4Testing3,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 > 3Testing5398,58462,320,2,768 > > So something is wrong with my Regex, but I can not figure out what? It > looks like it is matching against 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@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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Regex help needed...
I need some regex help. I have a list that is of the form: i.e. 1Testing1,7471,1,1,747 2Testing752,18001,752,1,1800 3Testing5398,58462,320,2,768 4Testing3,111.951,683.915,302.268,385.751 3,111.951,683.915,302.268,385.751 can have a list of number in 1 of 2 formats: A comma separated list of 4 integers, i.e. ,,, OR A comma separated list of 1 integer, followed by 4 decimal numbers, i.e. I need filter the lines of this list with a REGEX pattern to get lines WHERE a value pPage matches certain places in , specifically: where pPage is equal to either or in the first format(i.e. item 1 or item 3) OR where pPage is equal to 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: 1Testing1,7471,1,1,747 2Testing752,18001,752,1,1800 and I do. If pPage is 2 then I should get: 3Testing5398,58462,320,2,768 and I do. If pPage is 3 then I should get: 4Testing3,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 3Testing5398,58462,320,2,768 So something is wrong with my Regex, but I can not figure out what? It looks like it is matching against 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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Regex Help
Hi Skip, Not sure what can come before /after the string but here's a start .*/point-.*-landed\.html.* That will find your string with any number of chars before or after it. If you need to check for it at the start of a line, replace ".*" with a "^" at the start of the regexp. Pete lcSQL Software On Sep 26, 2014 2:04 PM, "Magicgate Software - Skip Kimpel" < s...@magicgate.com> wrote: > Hey LC / Regex gurus, > > I need help creating a regular expression that will filter out all > instances where the pattern looks like this: > > /point-XXX-landed.html > > Obviously the "XX" section varies from item to item and is also of > different character lengths. > > Anybody willing to give this a shot? > > SKIP > ___ > use-livecode mailing list > use-livecode@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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Regex Help
Michael, those are two awesome resources! Thanks. SKIP On Fri, Sep 26, 2014 at 7:23 PM, Michael Doub wrote: > Guys, I have been using these 2 sites lately and they are really a huge > help in understanding regex: > > http://regex101.com/#pcre > http://www.regexr.com > > Give them a try… > Mike > > > > On Sep 26, 2014, at 5:34 PM, Magicgate Software - Skip Kimpel < > s...@magicgate.com> wrote: > > > Thank you Mark! > > > > On Fri, Sep 26, 2014 at 4:58 PM, Mark Schonewille < > > m.schonewi...@economy-x-talk.com> wrote: > > > >> Hi Skip, > >> > >> If it contains numbers and letters, it could be > >> > >> /point-item[0-9a-zA-Z]+-landed.html > >> > >> and if it contains anything except whitespace, it could be > >> > >> /point-item[\w]+-landed.html > >> > >> Both options work with the sample data you provided. > >> > >> -- > >> Best regards, > >> > >> Mark Schonewille > >> > >> Economy-x-Talk Consulting and Software Engineering > >> Homepage: http://economy-x-talk.com > >> Twitter: http://twitter.com/xtalkprogrammer > >> KvK: 50277553 > >> > >> Installer Maker for LiveCode: > >> http://qery.us/468 > >> > >> Buy my new book "Programming LiveCode for the Real Beginner" > >> http://qery.us/3fi > >> > >> LiveCode on Facebook: > >> https://www.facebook.com/groups/runrev/ > >> > >> On 9/26/2014 22:54, Magicgate Software - Skip Kimpel wrote: > >> > >>> Sorry... it contains letters. Sorry for the confusion. I should have > >>> been > >>> more complete with my explanation and sample data. > >>> > >>> SKIP > >>> > >>> On Fri, Sep 26, 2014 at 4:51 PM, Mark Schonewille < > >>> m.schonewi...@economy-x-talk.com> wrote: > >>> > >>> Then what exactly does the middle item contain? Numbers and letters? > Special symbols? Chinese? > > -- > Best regards, > > Mark Schonewille > > Economy-x-Talk Consulting and Software Engineering > Homepage: http://economy-x-talk.com > Twitter: http://twitter.com/xtalkprogrammer > KvK: 50277553 > > Installer Maker for LiveCode: > http://qery.us/468 > > Buy my new book "Programming LiveCode for the Real Beginner" > http://qery.us/3fi > > LiveCode on Facebook: > https://www.facebook.com/groups/runrev/ > > On 9/26/2014 22:49, Magicgate Software - Skip Kimpel wrote: > > The middle item "X" does not always have a number in it. The > common > > denominator between all the items I WANT to keep start with "page-" > and > > end > > with "-landed.html" > > > > On Fri, Sep 26, 2014 at 4:37 PM, Mark Schonewille < > > m.schonewi...@economy-x-talk.com> wrote: > > > > Hi, > > > >> > >> Then you can try this: > >> > >> on mouseUp > >> put "/point-item[0-9]+-landed.html" into myFilter > >> put fld 1 into myData > >> filter myData with regex pattern myFilter > >> put myData > >> end mouseUp > >> > >> This is a LiveCode example, but you can apply the regex > >> "/point-item[0-9]+-landed.html" in PHP or Perl. I tried this with > and > >> without escaping the slash and dashes, but escaping seems > unnecesary. > >> If > >> the regex doesn't work in PHP or Perl, maybe you could try > >> > >> \/point\-item[0-9]+\-landed.html > >> > >> but I haven't tested if this would be necessary. > >> > >> -- > >> Best regards, > >> > >> Mark Schonewille > >> > >> Economy-x-Talk Consulting and Software Engineering > >> Homepage: http://economy-x-talk.com > >> Twitter: http://twitter.com/xtalkprogrammer > >> KvK: 50277553 > >> > >> Installer Maker for LiveCode: > >> http://qery.us/468 > >> > >> Buy my new book "Programming LiveCode for the Real Beginner" > >> http://qery.us/3fi > >> > >> LiveCode on Facebook: > >> https://www.facebook.com/groups/runrev/ > >> > >> On 9/26/2014 22:27, Magicgate Software - Skip Kimpel wrote: > >> > >> The results I want returned are: > >> > >>> > >>> > >>> ___ > >> use-livecode mailing list > >> use-livecode@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@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@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your > subscription preferences: > http://lists.runrev.com/mailman/listinfo
Re: Regex Help
Guys, I have been using these 2 sites lately and they are really a huge help in understanding regex: http://regex101.com/#pcre http://www.regexr.com Give them a try… Mike On Sep 26, 2014, at 5:34 PM, Magicgate Software - Skip Kimpel wrote: > Thank you Mark! > > On Fri, Sep 26, 2014 at 4:58 PM, Mark Schonewille < > m.schonewi...@economy-x-talk.com> wrote: > >> Hi Skip, >> >> If it contains numbers and letters, it could be >> >> /point-item[0-9a-zA-Z]+-landed.html >> >> and if it contains anything except whitespace, it could be >> >> /point-item[\w]+-landed.html >> >> Both options work with the sample data you provided. >> >> -- >> Best regards, >> >> Mark Schonewille >> >> Economy-x-Talk Consulting and Software Engineering >> Homepage: http://economy-x-talk.com >> Twitter: http://twitter.com/xtalkprogrammer >> KvK: 50277553 >> >> Installer Maker for LiveCode: >> http://qery.us/468 >> >> Buy my new book "Programming LiveCode for the Real Beginner" >> http://qery.us/3fi >> >> LiveCode on Facebook: >> https://www.facebook.com/groups/runrev/ >> >> On 9/26/2014 22:54, Magicgate Software - Skip Kimpel wrote: >> >>> Sorry... it contains letters. Sorry for the confusion. I should have >>> been >>> more complete with my explanation and sample data. >>> >>> SKIP >>> >>> On Fri, Sep 26, 2014 at 4:51 PM, Mark Schonewille < >>> m.schonewi...@economy-x-talk.com> wrote: >>> >>> Then what exactly does the middle item contain? Numbers and letters? Special symbols? Chinese? -- Best regards, Mark Schonewille Economy-x-Talk Consulting and Software Engineering Homepage: http://economy-x-talk.com Twitter: http://twitter.com/xtalkprogrammer KvK: 50277553 Installer Maker for LiveCode: http://qery.us/468 Buy my new book "Programming LiveCode for the Real Beginner" http://qery.us/3fi LiveCode on Facebook: https://www.facebook.com/groups/runrev/ On 9/26/2014 22:49, Magicgate Software - Skip Kimpel wrote: The middle item "X" does not always have a number in it. The common > denominator between all the items I WANT to keep start with "page-" and > end > with "-landed.html" > > On Fri, Sep 26, 2014 at 4:37 PM, Mark Schonewille < > m.schonewi...@economy-x-talk.com> wrote: > > Hi, > >> >> Then you can try this: >> >> on mouseUp >> put "/point-item[0-9]+-landed.html" into myFilter >> put fld 1 into myData >> filter myData with regex pattern myFilter >> put myData >> end mouseUp >> >> This is a LiveCode example, but you can apply the regex >> "/point-item[0-9]+-landed.html" in PHP or Perl. I tried this with and >> without escaping the slash and dashes, but escaping seems unnecesary. >> If >> the regex doesn't work in PHP or Perl, maybe you could try >> >> \/point\-item[0-9]+\-landed.html >> >> but I haven't tested if this would be necessary. >> >> -- >> Best regards, >> >> Mark Schonewille >> >> Economy-x-Talk Consulting and Software Engineering >> Homepage: http://economy-x-talk.com >> Twitter: http://twitter.com/xtalkprogrammer >> KvK: 50277553 >> >> Installer Maker for LiveCode: >> http://qery.us/468 >> >> Buy my new book "Programming LiveCode for the Real Beginner" >> http://qery.us/3fi >> >> LiveCode on Facebook: >> https://www.facebook.com/groups/runrev/ >> >> On 9/26/2014 22:27, Magicgate Software - Skip Kimpel wrote: >> >> The results I want returned are: >> >>> >>> >>> ___ >> use-livecode mailing list >> use-livecode@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@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@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@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@lists.ru
Re: Regex Help
Thank you Mark! On Fri, Sep 26, 2014 at 4:58 PM, Mark Schonewille < m.schonewi...@economy-x-talk.com> wrote: > Hi Skip, > > If it contains numbers and letters, it could be > > /point-item[0-9a-zA-Z]+-landed.html > > and if it contains anything except whitespace, it could be > > /point-item[\w]+-landed.html > > Both options work with the sample data you provided. > > -- > Best regards, > > Mark Schonewille > > Economy-x-Talk Consulting and Software Engineering > Homepage: http://economy-x-talk.com > Twitter: http://twitter.com/xtalkprogrammer > KvK: 50277553 > > Installer Maker for LiveCode: > http://qery.us/468 > > Buy my new book "Programming LiveCode for the Real Beginner" > http://qery.us/3fi > > LiveCode on Facebook: > https://www.facebook.com/groups/runrev/ > > On 9/26/2014 22:54, Magicgate Software - Skip Kimpel wrote: > >> Sorry... it contains letters. Sorry for the confusion. I should have >> been >> more complete with my explanation and sample data. >> >> SKIP >> >> On Fri, Sep 26, 2014 at 4:51 PM, Mark Schonewille < >> m.schonewi...@economy-x-talk.com> wrote: >> >> Then what exactly does the middle item contain? Numbers and letters? >>> Special symbols? Chinese? >>> >>> -- >>> Best regards, >>> >>> Mark Schonewille >>> >>> Economy-x-Talk Consulting and Software Engineering >>> Homepage: http://economy-x-talk.com >>> Twitter: http://twitter.com/xtalkprogrammer >>> KvK: 50277553 >>> >>> Installer Maker for LiveCode: >>> http://qery.us/468 >>> >>> Buy my new book "Programming LiveCode for the Real Beginner" >>> http://qery.us/3fi >>> >>> LiveCode on Facebook: >>> https://www.facebook.com/groups/runrev/ >>> >>> On 9/26/2014 22:49, Magicgate Software - Skip Kimpel wrote: >>> >>> The middle item "X" does not always have a number in it. The common denominator between all the items I WANT to keep start with "page-" and end with "-landed.html" On Fri, Sep 26, 2014 at 4:37 PM, Mark Schonewille < m.schonewi...@economy-x-talk.com> wrote: Hi, > > Then you can try this: > > on mouseUp >put "/point-item[0-9]+-landed.html" into myFilter >put fld 1 into myData >filter myData with regex pattern myFilter >put myData > end mouseUp > > This is a LiveCode example, but you can apply the regex > "/point-item[0-9]+-landed.html" in PHP or Perl. I tried this with and > without escaping the slash and dashes, but escaping seems unnecesary. > If > the regex doesn't work in PHP or Perl, maybe you could try > > \/point\-item[0-9]+\-landed.html > > but I haven't tested if this would be necessary. > > -- > Best regards, > > Mark Schonewille > > Economy-x-Talk Consulting and Software Engineering > Homepage: http://economy-x-talk.com > Twitter: http://twitter.com/xtalkprogrammer > KvK: 50277553 > > Installer Maker for LiveCode: > http://qery.us/468 > > Buy my new book "Programming LiveCode for the Real Beginner" > http://qery.us/3fi > > LiveCode on Facebook: > https://www.facebook.com/groups/runrev/ > > On 9/26/2014 22:27, Magicgate Software - Skip Kimpel wrote: > > The results I want returned are: > >> >> >> ___ > use-livecode mailing list > use-livecode@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@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@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@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@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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Regex Help
Hi Skip, If it contains numbers and letters, it could be /point-item[0-9a-zA-Z]+-landed.html and if it contains anything except whitespace, it could be /point-item[\w]+-landed.html Both options work with the sample data you provided. -- Best regards, Mark Schonewille Economy-x-Talk Consulting and Software Engineering Homepage: http://economy-x-talk.com Twitter: http://twitter.com/xtalkprogrammer KvK: 50277553 Installer Maker for LiveCode: http://qery.us/468 Buy my new book "Programming LiveCode for the Real Beginner" http://qery.us/3fi LiveCode on Facebook: https://www.facebook.com/groups/runrev/ On 9/26/2014 22:54, Magicgate Software - Skip Kimpel wrote: Sorry... it contains letters. Sorry for the confusion. I should have been more complete with my explanation and sample data. SKIP On Fri, Sep 26, 2014 at 4:51 PM, Mark Schonewille < m.schonewi...@economy-x-talk.com> wrote: Then what exactly does the middle item contain? Numbers and letters? Special symbols? Chinese? -- Best regards, Mark Schonewille Economy-x-Talk Consulting and Software Engineering Homepage: http://economy-x-talk.com Twitter: http://twitter.com/xtalkprogrammer KvK: 50277553 Installer Maker for LiveCode: http://qery.us/468 Buy my new book "Programming LiveCode for the Real Beginner" http://qery.us/3fi LiveCode on Facebook: https://www.facebook.com/groups/runrev/ On 9/26/2014 22:49, Magicgate Software - Skip Kimpel wrote: The middle item "X" does not always have a number in it. The common denominator between all the items I WANT to keep start with "page-" and end with "-landed.html" On Fri, Sep 26, 2014 at 4:37 PM, Mark Schonewille < m.schonewi...@economy-x-talk.com> wrote: Hi, Then you can try this: on mouseUp put "/point-item[0-9]+-landed.html" into myFilter put fld 1 into myData filter myData with regex pattern myFilter put myData end mouseUp This is a LiveCode example, but you can apply the regex "/point-item[0-9]+-landed.html" in PHP or Perl. I tried this with and without escaping the slash and dashes, but escaping seems unnecesary. If the regex doesn't work in PHP or Perl, maybe you could try \/point\-item[0-9]+\-landed.html but I haven't tested if this would be necessary. -- Best regards, Mark Schonewille Economy-x-Talk Consulting and Software Engineering Homepage: http://economy-x-talk.com Twitter: http://twitter.com/xtalkprogrammer KvK: 50277553 Installer Maker for LiveCode: http://qery.us/468 Buy my new book "Programming LiveCode for the Real Beginner" http://qery.us/3fi LiveCode on Facebook: https://www.facebook.com/groups/runrev/ On 9/26/2014 22:27, Magicgate Software - Skip Kimpel wrote: The results I want returned are: ___ use-livecode mailing list use-livecode@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@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@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@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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Regex Help
Sorry... it contains letters. Sorry for the confusion. I should have been more complete with my explanation and sample data. SKIP On Fri, Sep 26, 2014 at 4:51 PM, Mark Schonewille < m.schonewi...@economy-x-talk.com> wrote: > Then what exactly does the middle item contain? Numbers and letters? > Special symbols? Chinese? > > -- > Best regards, > > Mark Schonewille > > Economy-x-Talk Consulting and Software Engineering > Homepage: http://economy-x-talk.com > Twitter: http://twitter.com/xtalkprogrammer > KvK: 50277553 > > Installer Maker for LiveCode: > http://qery.us/468 > > Buy my new book "Programming LiveCode for the Real Beginner" > http://qery.us/3fi > > LiveCode on Facebook: > https://www.facebook.com/groups/runrev/ > > On 9/26/2014 22:49, Magicgate Software - Skip Kimpel wrote: > >> The middle item "X" does not always have a number in it. The common >> denominator between all the items I WANT to keep start with "page-" and >> end >> with "-landed.html" >> >> On Fri, Sep 26, 2014 at 4:37 PM, Mark Schonewille < >> m.schonewi...@economy-x-talk.com> wrote: >> >> Hi, >>> >>> Then you can try this: >>> >>> on mouseUp >>> put "/point-item[0-9]+-landed.html" into myFilter >>> put fld 1 into myData >>> filter myData with regex pattern myFilter >>> put myData >>> end mouseUp >>> >>> This is a LiveCode example, but you can apply the regex >>> "/point-item[0-9]+-landed.html" in PHP or Perl. I tried this with and >>> without escaping the slash and dashes, but escaping seems unnecesary. If >>> the regex doesn't work in PHP or Perl, maybe you could try >>> >>> \/point\-item[0-9]+\-landed.html >>> >>> but I haven't tested if this would be necessary. >>> >>> -- >>> Best regards, >>> >>> Mark Schonewille >>> >>> Economy-x-Talk Consulting and Software Engineering >>> Homepage: http://economy-x-talk.com >>> Twitter: http://twitter.com/xtalkprogrammer >>> KvK: 50277553 >>> >>> Installer Maker for LiveCode: >>> http://qery.us/468 >>> >>> Buy my new book "Programming LiveCode for the Real Beginner" >>> http://qery.us/3fi >>> >>> LiveCode on Facebook: >>> https://www.facebook.com/groups/runrev/ >>> >>> On 9/26/2014 22:27, Magicgate Software - Skip Kimpel wrote: >>> >>> The results I want returned are: >>> ___ >>> use-livecode mailing list >>> use-livecode@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@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@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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Regex Help
Then what exactly does the middle item contain? Numbers and letters? Special symbols? Chinese? -- Best regards, Mark Schonewille Economy-x-Talk Consulting and Software Engineering Homepage: http://economy-x-talk.com Twitter: http://twitter.com/xtalkprogrammer KvK: 50277553 Installer Maker for LiveCode: http://qery.us/468 Buy my new book "Programming LiveCode for the Real Beginner" http://qery.us/3fi LiveCode on Facebook: https://www.facebook.com/groups/runrev/ On 9/26/2014 22:49, Magicgate Software - Skip Kimpel wrote: The middle item "X" does not always have a number in it. The common denominator between all the items I WANT to keep start with "page-" and end with "-landed.html" On Fri, Sep 26, 2014 at 4:37 PM, Mark Schonewille < m.schonewi...@economy-x-talk.com> wrote: Hi, Then you can try this: on mouseUp put "/point-item[0-9]+-landed.html" into myFilter put fld 1 into myData filter myData with regex pattern myFilter put myData end mouseUp This is a LiveCode example, but you can apply the regex "/point-item[0-9]+-landed.html" in PHP or Perl. I tried this with and without escaping the slash and dashes, but escaping seems unnecesary. If the regex doesn't work in PHP or Perl, maybe you could try \/point\-item[0-9]+\-landed.html but I haven't tested if this would be necessary. -- Best regards, Mark Schonewille Economy-x-Talk Consulting and Software Engineering Homepage: http://economy-x-talk.com Twitter: http://twitter.com/xtalkprogrammer KvK: 50277553 Installer Maker for LiveCode: http://qery.us/468 Buy my new book "Programming LiveCode for the Real Beginner" http://qery.us/3fi LiveCode on Facebook: https://www.facebook.com/groups/runrev/ On 9/26/2014 22:27, Magicgate Software - Skip Kimpel wrote: The results I want returned are: ___ use-livecode mailing list use-livecode@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@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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Regex Help
The middle item "X" does not always have a number in it. The common denominator between all the items I WANT to keep start with "page-" and end with "-landed.html" On Fri, Sep 26, 2014 at 4:37 PM, Mark Schonewille < m.schonewi...@economy-x-talk.com> wrote: > Hi, > > Then you can try this: > > on mouseUp > put "/point-item[0-9]+-landed.html" into myFilter > put fld 1 into myData > filter myData with regex pattern myFilter > put myData > end mouseUp > > This is a LiveCode example, but you can apply the regex > "/point-item[0-9]+-landed.html" in PHP or Perl. I tried this with and > without escaping the slash and dashes, but escaping seems unnecesary. If > the regex doesn't work in PHP or Perl, maybe you could try > > \/point\-item[0-9]+\-landed.html > > but I haven't tested if this would be necessary. > > -- > Best regards, > > Mark Schonewille > > Economy-x-Talk Consulting and Software Engineering > Homepage: http://economy-x-talk.com > Twitter: http://twitter.com/xtalkprogrammer > KvK: 50277553 > > Installer Maker for LiveCode: > http://qery.us/468 > > Buy my new book "Programming LiveCode for the Real Beginner" > http://qery.us/3fi > > LiveCode on Facebook: > https://www.facebook.com/groups/runrev/ > > On 9/26/2014 22:27, Magicgate Software - Skip Kimpel wrote: > >> The results I want returned are: >> > > ___ > use-livecode mailing list > use-livecode@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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Regex Help
Hi, Then you can try this: on mouseUp put "/point-item[0-9]+-landed.html" into myFilter put fld 1 into myData filter myData with regex pattern myFilter put myData end mouseUp This is a LiveCode example, but you can apply the regex "/point-item[0-9]+-landed.html" in PHP or Perl. I tried this with and without escaping the slash and dashes, but escaping seems unnecesary. If the regex doesn't work in PHP or Perl, maybe you could try \/point\-item[0-9]+\-landed.html but I haven't tested if this would be necessary. -- Best regards, Mark Schonewille Economy-x-Talk Consulting and Software Engineering Homepage: http://economy-x-talk.com Twitter: http://twitter.com/xtalkprogrammer KvK: 50277553 Installer Maker for LiveCode: http://qery.us/468 Buy my new book "Programming LiveCode for the Real Beginner" http://qery.us/3fi LiveCode on Facebook: https://www.facebook.com/groups/runrev/ On 9/26/2014 22:27, Magicgate Software - Skip Kimpel wrote: The results I want returned are: ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Regex Help
Thanks Mark, Actually look for the regex version as I will be applying that externally before feeding into LC. Here is a sample of the data: /point-item1-landed.html /point-about.html /point-test.html /point-item2-landed.html /point-item300-landed.html The results I want returned are: /point-item1-landed.html /point-item2-landed.html /point-item300-landed.html Thanks for your input! On Fri, Sep 26, 2014 at 4:17 PM, Mark Schonewille < m.schonewi...@economy-x-talk.com> wrote: > Hi, > > It could be something like this: > > on mouseUp > put "*/point-*-landed.html" into myFilter > put fld 1 into myData > filter myData without myFilter > put myData > end mouseUp > > but if this doesn't work, you'll have to post an actual sample of your > data. > > -- > Best regards, > > Mark Schonewille > > Economy-x-Talk Consulting and Software Engineering > Homepage: http://economy-x-talk.com > Twitter: http://twitter.com/xtalkprogrammer > KvK: 50277553 > > Installer Maker for LiveCode: > http://qery.us/468 > > Buy my new book "Programming LiveCode for the Real Beginner" > http://qery.us/3fi > > LiveCode on Facebook: > https://www.facebook.com/groups/runrev/ > > > On 9/26/2014 22:04, Magicgate Software - Skip Kimpel wrote: > >> Hey LC / Regex gurus, >> >> I need help creating a regular expression that will filter out all >> instances where the pattern looks like this: >> >> /point-XXX-landed.html >> >> Obviously the "XX" section varies from item to item and is also of >> different character lengths. >> >> Anybody willing to give this a shot? >> >> SKIP >> > > > ___ > use-livecode mailing list > use-livecode@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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Regex Help
Hi, It could be something like this: on mouseUp put "*/point-*-landed.html" into myFilter put fld 1 into myData filter myData without myFilter put myData end mouseUp but if this doesn't work, you'll have to post an actual sample of your data. -- Best regards, Mark Schonewille Economy-x-Talk Consulting and Software Engineering Homepage: http://economy-x-talk.com Twitter: http://twitter.com/xtalkprogrammer KvK: 50277553 Installer Maker for LiveCode: http://qery.us/468 Buy my new book "Programming LiveCode for the Real Beginner" http://qery.us/3fi LiveCode on Facebook: https://www.facebook.com/groups/runrev/ On 9/26/2014 22:04, Magicgate Software - Skip Kimpel wrote: Hey LC / Regex gurus, I need help creating a regular expression that will filter out all instances where the pattern looks like this: /point-XXX-landed.html Obviously the "XX" section varies from item to item and is also of different character lengths. Anybody willing to give this a shot? SKIP ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Regex Help
Hey LC / Regex gurus, I need help creating a regular expression that will filter out all instances where the pattern looks like this: /point-XXX-landed.html Obviously the "XX" section varies from item to item and is also of different character lengths. Anybody willing to give this a shot? SKIP ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: regex help please
Your training is almost complete. Destroy Darth Vader and take his place at my side! Mooo haah haah haha hahah ahah! Bob On Feb 9, 2012, at 12:24 PM, Klaus on-rev wrote: > So with this text above in tText and "tag2" int tTag: > > function mk_getXMLdata tText, tTag > get matchText(tText,"(?s)<" & tTag & ">(.*?)",tValue) > return tValue > end mk_getXMLdata > > will give : more bla bla > So far so good, I even almost understand the reg ex ;-) ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: regex help please
Hi friends, thank you all for your help, i got it to work now! Again thanks a lot! Best Klaus -- Klaus Major http://www.major-k.de kl...@major.on-rev.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: regex help please
On Thu, Feb 9, 2012 at 7:10 PM, Klaus on-rev wrote: > Hi Andre, > > Am 09.02.2012 um 22:05 schrieb Andre Garzia: > > > Klaus, > > > > Since you have control, then instead of RegEx, you can go like > > > > > > nodecontent > > > > > > All in different lines, then, you can just use lineOffset to find the > start > > node and the end node and copy or replace the data between those lines. > > It is easier than RegEx. > > well, that's what I want to find out by myself, but can't without the > appropriate reg ex ;-) > Klaus, If you create the XML like I placed above you can replace content with something like: command replaceXMLNodeContent pNode, @pXML, pNewContent put "<" & pNode & ">" into tStartNode put "" into tEndNode put lineOffset(tStartNode, pXML) into tStartLine put lineOffset(tEndNode, pXML, tStartLine) into tEndLine put line tStartLine to tEndLine of pXML into tNodeContent replace (tStartNode & cr & tNodeContent & cr & tEndNode) with (tStartNode & cr & pNewContent & cr & tEndNode) in pXML end replaceXMLNodeContent > > > Best > > Klaus > > -- > Klaus Major > http://www.major-k.de > kl...@major.on-rev.com > > > ___ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your > subscription preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode > -- http://www.andregarzia.com -- All We Do Is Code. http://fon.nu -- minimalist url shortening service. ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: regex help please
>> Nonetheless, if you want to continue down the regex path, try >> something like >> >> get matchText(tText,"(?s)<" & tTag & ">(.*?)",tValue) >> replace "<" & tTag & ">" & tValue " with >> "<" & tTag & ">" & tNewValue " >> in tText > > well, I did not want to pass the text that I want to overwrite in the XML, > which I do not now in that moment! > But this is neccesary in Mark's and "zalgo/tony the coming pony"s (? :-D > ) scripts. > > I only want to pass the XML text, the tagname and the NEW text to be place > inside of these tags. Mark Weider's code will work for you, Klaus… the "tValue" is something that the matchText function FILLS with the current text inside the brackets, so you don't need to know it ahead of time. The "(.*?)" is a way to "capture" what is between the tags, and the 3rd+ parameters to he matchTextFunction are variables that are provided to the function that get filled with whatever is being captured. The matchText function returns either 'true' (if it can find what you are looking for) or 'false') if it can't. Mark's code above assumes a 'true' result by using "get". Here's an example that takes into account the possibility that you may not match what you're looking for: put "Hello" into tData if matchText(tData,"(?s)(.*?)",tValue) = "true" then put tValue -- Since this matches, you'll get "Hello" in the msg box else put "No Match" end if > Ken Ray Sons of Thunder Software, Inc. Email: k...@sonsothunder.com Web Site: http://www.sonsothunder.com/ ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: regex help please
On 09/02/2012 21:00, Klaus on-rev wrote: get matchText(tText,"(?s)<"& tTag& ">(.*?)",tValue) replace "<"& tTag& ">"& tValue" with "<"& tTag& ">"& tNewValue" in tText well, I did not want to pass the text that I want to overwrite in the XML, which I do not now in that moment! But this is neccesary in Mark's and "zalgo/tony the coming pony"s (? :-D ) scripts. I only want to pass the XML text, the tagname and the NEW text to be place inside of these tags. Any other hints? You might take a look at the code again. In both cases you hand in the whole XML text, the tag you want to replace, and the value you want to stuff into it. The matchText function gets the current value in that tag. Mark's replace above (or my replaceText) replace that, and return the result. -Ken ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: regex help please
Hi Andre, Am 09.02.2012 um 22:05 schrieb Andre Garzia: > Klaus, > > Since you have control, then instead of RegEx, you can go like > > > nodecontent > > > All in different lines, then, you can just use lineOffset to find the start > node and the end node and copy or replace the data between those lines. > It is easier than RegEx. well, that's what I want to find out by myself, but can't without the appropriate reg ex ;-) Best Klaus -- Klaus Major http://www.major-k.de kl...@major.on-rev.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: regex help please
Klaus, Since you have control, then instead of RegEx, you can go like nodecontent All in different lines, then, you can just use lineOffset to find the start node and the end node and copy or replace the data between those lines. It is easier than RegEx. On Thu, Feb 9, 2012 at 6:54 PM, Klaus on-rev wrote: > Hi Andre, > > Am 09.02.2012 um 21:38 schrieb Andre Garzia: > > > Klaus, > > > > I used to work like that, doing little XML files with RegEx and > matchText. > > After working like that for a long time, I came to realize that there was > > no advantage at all in my case. It was simpler to work with RevXML. The > > problem with RegEx is all the little cases where it fails. I think you > > should use RevXML, it might look overkill but it will cut your debug > time a > > lot. > > than you for your insight, but in this project I have complete control > over the XML > and thus will not get any surprises :-) > > > Cheers > > andre > > Best > > Klaus > > -- > Klaus Major > http://www.major-k.de > kl...@major.on-rev.com > > > ___ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your > subscription preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode > -- http://www.andregarzia.com -- All We Do Is Code. http://fon.nu -- minimalist url shortening service. ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: regex help please
Hi guys, Am 09.02.2012 um 21:52 schrieb Mark Wieder: > Klaus, > > What Andre said. Sigh... :-) > Nonetheless, if you want to continue down the regex path, try > something like > > get matchText(tText,"(?s)<" & tTag & ">(.*?)",tValue) > replace "<" & tTag & ">" & tValue " with > "<" & tTag & ">" & tNewValue " > in tText well, I did not want to pass the text that I want to overwrite in the XML, which I do not now in that moment! But this is neccesary in Mark's and "zalgo/tony the coming pony"s (? :-D ) scripts. I only want to pass the XML text, the tagname and the NEW text to be place inside of these tags. Any other hints? > -- > Mark Wieder Best Klaus -- Klaus Major http://www.major-k.de kl...@major.on-rev.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: regex help please
Hi Andre, Am 09.02.2012 um 21:38 schrieb Andre Garzia: > Klaus, > > I used to work like that, doing little XML files with RegEx and matchText. > After working like that for a long time, I came to realize that there was > no advantage at all in my case. It was simpler to work with RevXML. The > problem with RegEx is all the little cases where it fails. I think you > should use RevXML, it might look overkill but it will cut your debug time a > lot. than you for your insight, but in this project I have complete control over the XML and thus will not get any surprises :-) > Cheers > andre Best Klaus -- Klaus Major http://www.major-k.de kl...@major.on-rev.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: regex help please
Klaus, What Andre said. Nonetheless, if you want to continue down the regex path, try something like get matchText(tText,"(?s)<" & tTag & ">(.*?)",tValue) replace "<" & tTag & ">" & tValue " with "<" & tTag & ">" & tNewValue " in tText -- Mark Wieder ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: regex help please
On 09/02/2012 20:24, Klaus on-rev wrote: in my current project I need to deal with VERY small XML files with maybe up to 20 entries. Wait, didn't we just hear that you can't parse html (or XML) with regexps? *grin* function mk_getXMLdata tText, tTag get matchText(tText,"(?s)<"& tTag& ">(.*?)",tValue) return tValue end mk_getXMLdata Throwing caution to the winds, this probably does something similar to what you want without further regexp voodoo: function mk_replaceXMLdata tText, tTag, tNewText put tText into tValue if matchText(tText,"(?s)<"& tTag& ">(.*?)",tValue) then put replaceText(tText, \ "<"&tTag&">"&tValue&"",\ "<"&tTag&">"&tNewText&"") into tValue end if return tValue end mk_replaceXMLdata And remember: zalgo is tony the pony! He's a comin! -Ken ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: regex help please
Klaus, I used to work like that, doing little XML files with RegEx and matchText. After working like that for a long time, I came to realize that there was no advantage at all in my case. It was simpler to work with RevXML. The problem with RegEx is all the little cases where it fails. I think you should use RevXML, it might look overkill but it will cut your debug time a lot. Cheers andre On Thu, Feb 9, 2012 at 6:24 PM, Klaus on-rev wrote: > Hi friends, > > in my current project I need to deal with VERY small XML files > with maybe up to 20 entries. > > So using the XML external seems to be a bit overkill. > > Some time ago I found a little reg ex here on the list which I turned > into a function and will return me everything inside of a given XML tag: > ... > bla bla > more bla bla > ... > > So with this text above in tText and "tag2" int tTag: > > function mk_getXMLdata tText, tTag > get matchText(tText,"(?s)<" & tTag & ">(.*?)",tValue) > return tValue > end mk_getXMLdata > > will give : more bla bla > So far so good, I even almost understand the reg ex ;-) > > Now I am looking for another little snippet to (over) write something > in(to) > a certain TAG, know what I mean? > > If someone could supply a nifty "replacetext" snippet that would be great! > :-) > Thanks in advance! > > > Best > > Klaus > > -- > Klaus Major > http://www.major-k.de > kl...@major.on-rev.com > > > ___ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your > subscription preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode > -- http://www.andregarzia.com -- All We Do Is Code. http://fon.nu -- minimalist url shortening service. ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
regex help please
Hi friends, in my current project I need to deal with VERY small XML files with maybe up to 20 entries. So using the XML external seems to be a bit overkill. Some time ago I found a little reg ex here on the list which I turned into a function and will return me everything inside of a given XML tag: ... bla bla more bla bla ... So with this text above in tText and "tag2" int tTag: function mk_getXMLdata tText, tTag get matchText(tText,"(?s)<" & tTag & ">(.*?)",tValue) return tValue end mk_getXMLdata will give : more bla bla So far so good, I even almost understand the reg ex ;-) Now I am looking for another little snippet to (over) write something in(to) a certain TAG, know what I mean? If someone could supply a nifty "replacetext" snippet that would be great! :-) Thanks in advance! Best Klaus -- Klaus Major http://www.major-k.de kl...@major.on-rev.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode