print "Matches: " . preg_match('/((?i)rah)\s+\1/', "rah rah") .
is what you should use.
[EMAIL PROTECTED] wrote:
I must be missing something obvious ... I am trying to use backreferences in a PCRE regexp to check for a repeated character, but they don't seem to work. I've used regexps often before, but never needed backreferences.
For example this:
print "Matches: " . preg_match("/(a)\1/", "aa");
prints:
Matches: 0
It should be 1.
In addition the basic examples in the manual fail. The manual says:
For example, ((?i)rah)\s+\1 matches "rah rah" and "RAH RAH", but
not "RAH rah", even though the original capturing subpattern is
matched caselessly.
I tested this with:
print "Matches: " . preg_match("/((?i)rah)\s+\1/", "RAH RAH") . "\n";
print "Matches: " . preg_match("/((?i)rah)\s+\1/", "rah rah") . "\n";
Both show 0.
For this test I'm running PHP 4.3.1 on Windows 2000.
What am I missing?
-- Tom
--
Raditha Dissanayake.
---------------------------------------------------------------
http://www.radinks.com/upload/ Drag and Drop Upload thousands of files and folders in a single
transfer. (HTTP or FTP)
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php