php.net |  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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: torke at lagged dot ca
New email:
PHP Version: OS:

 

 [2003-12-09 22:23 UTC] 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.




Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-12-10 04:30 UTC] 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-10 19:28 UTC] pollita@php.net
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-2020 The PHP Group
All rights reserved.
Last updated: Tue Nov 24 04:01:23 2020 UTC