Re: [PHP] Re: regexp questions
oops! Please see the change log for version 8.00 on http://www.pcre.org/changelog.txt Shiplu Mokadd.im My talks, http://talk.cmyweb.net Follow me, http://twitter.com/shiplu SUST Programmers, http://groups.google.com/group/p2psust Innovation distinguishes bet ... ... (ask Steve Jobs the rest)
Re: [PHP] Re: regexp questions
On Tue, 2010-05-11 at 23:29 +0700, shiplu wrote: > I think the error is related to changed described here. > http://www.pcre.org/changelog.txt > > Shiplu Mokadd.im > My talks, http://talk.cmyweb.net > Follow me, http://twitter.com/shiplu > SUST Programmers, http://groups.google.com/group/p2psust > Innovation distinguishes bet ... ... (ask Steve Jobs the rest) > That's quite a long document, care to narrow it down slightly? :p Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Re: regexp questions
I think the error is related to changed described here. http://www.pcre.org/changelog.txt Shiplu Mokadd.im My talks, http://talk.cmyweb.net Follow me, http://twitter.com/shiplu SUST Programmers, http://groups.google.com/group/p2psust Innovation distinguishes bet ... ... (ask Steve Jobs the rest) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: regexp appears to be faulty!?
On Tue, 2004-02-24 at 10:49, Henry Grech-Cini wrote: > http://www.alpha-geek.com/2003/12/31/do_not_do_not_parse_html_with_regexs.html > > Do we all agree or should I keep trying? The important thing to keep in mind here is to use the right tool for the job. If you are parsing an HTML document looking for tags, attributes, etc. I do recommend using domxml/simplexml/some XML parsing tool to get your job done quickly and cleanly. However, if you have a very specific need to extract some text from a string then you can probably get away with regular expressions. The big catch with regexp is that it has a very low reuse value. Generally regexps are difficult to read and rarely will you just copy and pate a regular expression from one piece of code to another. If your regexp is growing beyond one line and is taking a long time to process then it is time to move on. Additionally, regular expressions are not good at providing context. It just so happens that HTML documents are just text documents so if you can parse the text to get what you need great. However, if you want to move through the elements and attributes, you want something more powerful, like XPath or XQuery. (ie. you want to find the third fieldset child of the body element that has an attribute set to "foo") As a side note, that article has a link to a similar one that lists a regexp based XML parser as the only PHP solution. :) -- Adam Bregenzer [EMAIL PROTECTED] http://adam.bregenzer.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: regexp: 'a correctly parenthesized substring advanced'
hi marek, thanx for your suggestion. i have tried out the tokenizer but 1. i think its not realy final and can change in the future 2. the tokenizer can only find real php code but i need to find my simplified php code without an ; on the end of an statement for example. so the tokenizer doesn't do my job. i'm not far from the right solution it's a litle step to bring the regex working with embeded parenthesis beetween " " i only had 2pregs in the complete source that can catch any type of registered function call with the simplified syntax ... this is fast enough for me ... "Marek Kilimajer" <[EMAIL PROTECTED]> schrieb im Newsbeitrag news:[EMAIL PROTECTED] > Forget regexp and try this function: > http://sk.php.net/manual/en/function.token-get-all.php > > Jaaboo wrote: > > > I give an wrong example. Here is a better one > > > > > > > $txt = "func1($par1," 100 (euro)", func2($par2,"(c) by nobody"))"; > > > > if (preg_match_all(' > > > > / > > > > ([a-zA-Z]\w*?) > > > > \s* > > > > ( > > > > \( > > > > ( > > > > (?>.*?)| > > > > .*?(?R)* > > > > ) > > > > \) > > > > )+ > > > > /x > > > > ', $txt, $m)){ > > > > print_r($m); > > > > } else { > > > > echo "no match"; > > > > } > > > > echo "\n"; > > > > > > > > ?> > > > > This must result in : > > > > First call: func1($par1," 100 (euro)", func2($par2,"(c) by nobody")) > > Second call with the inner part $par1," 100 (euro)", func2($par2,"(c) by > > nobody") > > must result in : func2($par2,"(c) by nobody") > > > > > > > > Please visit www.regexp.org there is an open thread of this question. > > > > thanx > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: regexp: 'a correctly parenthesized substring advanced'
Forget regexp and try this function: http://sk.php.net/manual/en/function.token-get-all.php Jaaboo wrote: I give an wrong example. Here is a better one $txt = "func1($par1," 100 (euro)", func2($par2,"(c) by nobody"))"; if (preg_match_all(' / ([a-zA-Z]\w*?) \s* ( \( ( (?>.*?)| .*?(?R)* ) \) )+ /x ', $txt, $m)){ print_r($m); } else { echo "no match"; } echo "\n"; ?> This must result in : First call: func1($par1," 100 (euro)", func2($par2,"(c) by nobody")) Second call with the inner part $par1," 100 (euro)", func2($par2,"(c) by nobody") must result in : func2($par2,"(c) by nobody") Please visit www.regexp.org there is an open thread of this question. thanx -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: REGEXP
> > > > This is wrong. It should be > > Content-Type: multipart/mixed; > > boundary="B42DA66C4EC07C9B572A58FC" > > > > I don't know why it is not reading the whole string. It seems to treat > > the *boundary* part as another line. > > It _is_ another line; it just happens to starts with whitespace. > check RFC822. No doubt. > > If you have the whole message in a string (psuedo-code): Huh.. Then the below should work. But the stupid header breaks :) > > list ($h,$msg) =split("\n\n", $mailmsg); > > $h=str_replace("\t", " ", $h); // -> > $h=str_replace("\n ", " ", $h); // -> > // i.e. continuation of prior line > > $hdrs=split("\n", $h); > > ... > > Regards, > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Re: REGEXP
On 16-Jul-01 Adrian D'Costa wrote: > Hi James, > > Thanks for your mail. But I think the problem like somewhere else. > > I have the following: > echo $buffer; > There result : > Content-Type: multipart/mixed; > > This is wrong. It should be > Content-Type: multipart/mixed; > boundary="B42DA66C4EC07C9B572A58FC" > > I don't know why it is not reading the whole string. It seems to treat > the *boundary* part as another line. It _is_ another line; it just happens to starts with whitespace. check RFC822. If you have the whole message in a string (psuedo-code): list ($h,$msg) =split("\n\n", $mailmsg); $h=str_replace("\t", " ", $h); // -> $h=str_replace("\n ", " ", $h); // -> // i.e. continuation of prior line $hdrs=split("\n", $h); ... Regards, -- Don Read [EMAIL PROTECTED] -- It's always darkest before the dawn. So if you are going to steal the neighbor's newspaper, that's the time to do it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]