ID:               21422
 Updated by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
-Status:           Open
+Status:           Bogus
 Bug Type:         *Regular Expressions
 Operating System: Linux
 PHP Version:      4.3.0
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Your script is the evidence that preg_* is greedy by default, because
\w+ consumes as many characters as possible - letters and digits as
well. The last digit is not used because \d+ must match at least one
digit in order that the whole expression succeeds.

Ask for help on the mailing list to figure out the proper regexp.


Previous Comments:
------------------------------------------------------------------------

[2003-01-05 01:37:07] [EMAIL PROTECTED]

Perl regexps are greedy by default.  \d+ will get all decimals possible
(\d+? will only find one - it's lazy).  It seems preg_match is not
greedy by default.

code:
preg_match("/^\w+(\d+)$/", $change_link, $change_id);
print("My ID is $change_id[1]<BR>");

when passed: "edit11"
change_id[1] is equal to "1".  It should be equal to "11" especially
when my regexp is looking for the end of the line ($) after it!

------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=21422&edit=1

Reply via email to