|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26573 "?" repetition operator causing REG_BADRPT
Submitted: 2003-12-09 22:23 UTC Modified: 2003-12-10 19:28 UTC
From: torke at lagged dot ca Assigned:
Status: Not a bug Package: Regexps related
PHP Version: 4.3.4 OS: Slackware Linux (2.4.18)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: torke at lagged dot ca
New email:
PHP Version: OS:


 [2003-12-09 22:23 UTC] torke at lagged dot ca
Using an expression such as ".*?" causes unwelcome results.

When the code below is put through a validator ( 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!"); ?>

Expected result:
That eregi example should return TRUE.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-12-10 04:30 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

.*? 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:

 [2003-12-10 19:28 UTC]
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.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jul 14 21:01:27 2024 UTC