php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23276 eregi() regexp trouble - very weird.
Submitted: 2003-04-18 19:53 UTC Modified: 2003-04-18 21:39 UTC
From: lukas at hej dot nu Assigned:
Status: Not a bug Package: Regexps related
PHP Version: 4.3.1 OS: Linux Slackware 8.1
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
37 + 41 = ?
Subscribe to this entry?

 
 [2003-04-18 19:53 UTC] lukas at hej dot nu
This code:
<box bgcolor="#C6C6C6" bordercolor="#000000" top="1800" left="10" width="100" height="30" padding="5" borderwidth="1">

Won't match this RegExp in eregi():
<BOX bgcolor="(aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|purple|red|silver|teal|white|yellow|#[0-9a-f]{6})" bordercolor="(aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|purple|red|silver|teal|white|yellow|#[0-9a-f]{6})" top="([0-9]{1,3})" left="([0-9]{1,3})" width="([0-9]{1,3})" height="([0-9]{1,3})" padding="([0-9]{1})" borderwidth="([0-9]{1})">

It worked fine in PHP 4.2.x, but now in PHP 4.3.1 it doesn't.

An interesting notice might be that the code mentioned above will match this RegExp in eregi():
<BOX bgcolor="(aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|purple|red|silver|teal|white|yellow|#[0-9a-f]{6})" bordercolor="(aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|purple|red|silver|teal|white|yellow|#[0-9a-f]{6})" top="([0-9]{1,3})

Code example:
<?
if(eregi('<BOX bgcolor="(aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|purple|red|silver|teal|white|yellow|#[0-9a-f]{6})" bordercolor="(aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|purple|red|silver|teal|white|yellow|#[0-9a-f]{6})" top="([0-9]{1,3})" left="([0-9]{1,3})" width="([0-9]{1,3})" height="([0-9]{1,3})" padding="([0-9]{1})" borderwidth="([0-9]{1})">',
'<box bgcolor="#C6C6C6" bordercolor="#000000" top="1800" left="10" width="100" height="30" padding="5" borderwidth="1">'))
{
echo "Match";
}
else
{
echo "No match";
}
?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-04-18 20:02 UTC] lukas at hej dot nu
This string:
<box bgcolor="#C6C6C6" bordercolor="#000000" top="1800" left="10"
width="100" height="30" padding="5" borderwidth="1">

Won't match this RegExp in eregi():
<BOX
bgcolor="(aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|purp
le|red|silver|teal|white|yellow|#[0-9a-f]{6})"
bordercolor="(aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|
purple|red|silver|teal|white|yellow|#[0-9a-f]{6})" top="([0-9]{1,3})"
left="([0-9]{1,3})" width="([0-9]{1,3})" height="([0-9]{1,3})"
padding="([0-9]{1})" borderwidth="([0-9]{1})">

It worked fine in PHP 4.2.x, but now in PHP 4.3.1 it doesn't.

An interesting notice might be that the string mentioned above will match
this RegExp in eregi():
<BOX
bgcolor="(aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|purp
le|red|silver|teal|white|yellow|#[0-9a-f]{6})"
bordercolor="(aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|
purple|red|silver|teal|white|yellow|#[0-9a-f]{6})" top="([0-9]{1,3})

Code example:
<?
if(eregi('<BOX
bgcolor="(aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|purp
le|red|silver|teal|white|yellow|#[0-9a-f]{6})"
bordercolor="(aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|
purple|red|silver|teal|white|yellow|#[0-9a-f]{6})" top="([0-9]{1,3})"
left="([0-9]{1,3})" width="([0-9]{1,3})" height="([0-9]{1,3})"
padding="([0-9]{1})" borderwidth="([0-9]{1})">',
'<box bgcolor="#C6C6C6" bordercolor="#000000" top="1800" left="10"
width="100" height="30" padding="5" borderwidth="1">'))
{
echo "Match";
}
else
{
echo "No match";
}
?>
 [2003-04-18 20:07 UTC] lukas at hej dot nu
I thought I could change the original description, but it added a description instead. Well, all I wanted to change was "code" to "string".
 [2003-04-18 21:25 UTC] lukas at hej dot nu
I think everything was a stupid mistake :P
 [2003-04-18 21:26 UTC] lukas at hej dot nu
Well, it was. Sorry.
 [2003-04-18 21:39 UTC] magnus@php.net
On request.. 
Not a bug => Bogus 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 06:01:28 2024 UTC