View Single Post
Old 05-05-2008, 12:27 AM   #7 (permalink)
Salathe
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

My initial paragraph was aimed at delayedinsanity, which I assumed was clear from the response. Oops!

The tildes are acceptable delimiters for the PCRE extension (preg_* functions -- which should be used rather than the ereg* functions), the more usual delimiter (a character which signifies the start and end of the pattern) is the forward slash (e.g. /abc/).

The D modifier means that (to quote the PHP manual) "a dollar metacharacter in the pattern matches only at the end of the subject string. Without this modifier, a dollar also matches immediately before the final character if it is a newline (but not before any other newlines)."

Practically speaking, if we have a string which ends in a newline character "abc\n" then /^abc$/ would be successful whereas /^abc$/D would not match because the 'c' character isn't the absolute final character in the string.

Fuller information can be found in the PHP manual's PCRE Section.
Salathe is offline  
Reply With Quote