* Jan <[EMAIL PROTECTED]>: > Could someone explain to me the use of the vertical bar in > expressions like "|<[^>]+>(.*)</[^>]+>|U". I understand that the > vertical bars are used to separate the expression from the modifier, > but can't find any documentation about the reasons and rules to do > this.
This works in the PCRE functions, and has to do with the P in PCRE -- Perl. In perl, when performing a regexp, you can use whatever character you desire to act as 'quotes' surrounding it. The typical one is a forward slash, but when you are going to be matching forward slashes, this can be inconvenient (the following examples are all perl, with a PHP version follwing): if ( /http:\/\/www.php.net\// ) # perl if (preg_match('/http:\/\/www.php.net\//', $url)) # PHP You get what's called 'leaning toothpick' syndrome. So, to make things easier, you can specifiy a different regex delimiter: if ( m|http://www.php.net| ) # perl if (preg_match('|http://www.php.net|', $url) # PHP (In perl, the 'm' indicates you're doing a match operation, and needs to be present if you're using a delimiter other than a slash; it's not necessary in PHP as it's implied.) The modifier occurs after the delimiters -- and this can happen regardless of delimiter: if ( m|http://www.php.net|U ) # perl if (preg_match('|http://www.php.net|U', $url) # PHP if ( /http:\/\/www.php.net\//U ) # perl if (preg_match('/http:\/\/www.php.net\//U', $url) # PHP If you want more information on this, pick up a copy of "Mastering Regular Expressions" or "Programming Perl", both from O'Reilly Press. -- Matthew Weier O'Phinney | WEBSITES: Webmaster and IT Specialist | http://www.garden.org National Gardening Association | http://www.kidsgardening.com 802-863-5251 x156 | http://nationalgardenmonth.org mailto:[EMAIL PROTECTED] | http://vermontbotanical.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php