php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #14933 regular expression problem
Submitted: 2002-01-08 15:13 UTC Modified: 2002-01-10 08:06 UTC
From: rajko at fly dot cc dot fer dot hr Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 4.1.1 OS: Win ME
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: rajko at fly dot cc dot fer dot hr
New email:
PHP Version: OS:

 

 [2002-01-08 15:13 UTC] rajko at fly dot cc dot fer dot hr
Documentation quote:
     The character types \d, \D, \s, \S,  \w,  and  \W  may  also appear  in  a  character  class, and add the characters that they match to the class.

So, I tried to match "<T>try8" with
"<T>([\da-z]{1,})" and it won't work.

vs

"<T>([\da-z8]{1,})" work. !!
 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-01-08 15:28 UTC] irc-html@php.net
The document is correct on this issue, those character types may be used.

I've tested your code as:

if (ereg('<T>([\da-z]{1,})', '<T>try8')) { echo 'match'; }

Which, works just fine on win32 platforms, 4.1.1.  You may want to ensure there is no whitespace in the string you are testing.

Status -> Bogus
 [2002-01-10 07:19 UTC] rajko at fly dot cc dot fer dot hr
'Bug' withdrawn.

I mixed up perl & posix? :(  SORRY.

 [2002-01-10 08:06 UTC] rajko at fly dot cc dot fer dot hr
Regarding this reply I just want to make clear what was not working at my comp.

here is code which I used :

<?php
echo "*** POSIX<BR>\n";
if (eregi("<T>([\da-z\ ]{1,})", "<T>qw e1 asd!zxc", $out)) {
	echo "found=".count($out)."<BR>\n";
	foreach($out as $val) {
		echo "=$val<BR>\n";
	}
}
echo "<BR>*** PERL<BR>\n";
if (preg_match("/<T>([\d\ a-z]{1,})!([\w]+)/", "<T>qw e1 asd!zxc", $out)) {
	echo "found=".count($out)."<BR>\n";
	foreach($out as $val) {
		echo "=$val<BR>\n";
	}
}
?>

and output in my browses was:

*** POSIX
found=10
=qw e
=qw e
=
=
=
=
=
=
=
=

*** PERL
found=3
=qw e1 asd!zxc
=qw e1 asd
=zxc

See, there is difference even if match is found, but \d is not the same as in perl.
And I don't know what \d does in POSIX(probeable nothing)?
(Still checking documentation). :)

PS Just trying to help. :)

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue May 06 15:01:30 2025 UTC