#26573 [Bgs]: "?" repetition operator causing REG_BADRPT
ID: 26573
Updated by: pollita@php.net
Reported By: torke at lagged dot ca
Status: Bogus
Bug Type: Regexps related
Operating System: Slackware Linux (2.4.18)
PHP Version: 4.3.4
New Comment:
FWIW, .*? is a valid pattern.... In PCRE regex only.
The validator used probably assumed the pattern was PCRE and not EREG.
Use preg_match() instead.
Previous Comments:
------------------------------------------------------------------------
[2003-12-10 04:30:46] eru@php.net
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
.*? is not a valid regular expression, because the ? is referring to
the * and not .* - Solution is to put parenthesis around the pattern,
(.*)? works just fine. Apparently the regexp validator you used is
faulty. Interesting read on that subject:
http://www.pasc.org/interps/unofficial/db/p1003.2/pasc-1003.2-85.html
------------------------------------------------------------------------
[2003-12-09 22:23:31] torke at lagged dot ca
Description:
------------
Using an expression such as ".*?" causes unwelcome results.
When the code below is put through a validator
(http://regexlib.com/RETester.aspx) the regular expression matches the
text correctly.
Configure Command './configure' '--prefix=/usr'
'--with-apxs=/usr/local/apache/bin/apxs' '--with-mod_charset'
'--enable-force-cgi-redirect' '--enable-discard-path'
'--with-config-file-path=/usr/local/apache/conf' '--enable-safe-mode'
'--with-openssl' '--enable-bcmath' '--with-bz2'
'--enable-calendar'
'--enable-ctype' '--with-gdbm' '--enable-dbase'
'--enable-ftp'
'--with-gmp' '--with-mysql=/usr/local/mysql' '--with-xml=shared'
'--with-readline=/usr' '--enable-shmop' '--enable-sockets'
'--with-regex=php' '--enable-sysvsem' '--enable-sysvshm'
'--enable-yp'
'--enable-memory-limit' '--with-tsrm-pthreads' '--enable-shared'
'--disable-debug' '--with-zlib=/usr' '--enable-exif'
'--enable-xml'
'--with-expat' '--with-imap=/usr/local/imap-2002b' '--with-mcrypt'
'--with-gd' '--with-snmp'
Reproduce code:
---------------
<? echo eregi("^.*?!.*?@.agged\.ca$","Torke!torke@lagged.ca"); ?>
Expected result:
----------------
That eregi example should return TRUE.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=26573&edit=1
Thread (3 messages)