Alternation

Vertical bar characters are used to separate alternative patterns. For example, the pattern gilbert|sullivan matches either "gilbert" or "sullivan". Any number of alternatives may appear, and an empty alternative is permitted (matching the empty string). The matching process tries each alternative in turn, from left to right, and the first one that succeeds is used. If the alternatives are within a subpattern (defined below), "succeeds" means matching the rest of the main pattern as well as the alternative in the subpattern.

Коментарии

code:
<?php
$match
='';
echo 
'result = ' preg_match'/gilbert|sullivan/''gilbert'$match ) .PHP_EOL;
var_dump$match );
echo 
'result = ' preg_match'/gilbert|sullivan/''sullivan'$match ) .PHP_EOL;
var_dump$match );
?>

output:

result = 1
array(1) {
  [0]=>
  string(7) "gilbert"
}
result = 1
array(1) {
  [0]=>
  string(8) "sullivan"
}
2012-07-11 12:21:41
http://php5.kiev.ua/manual/ru/regexp.reference.alternation.html

    Поддержать сайт на родительском проекте КГБ