very ordinary-looking women{regular|standard}wired phenomenon in the job{et|etplace}but in most of 还有以上 }wired phenomenon in the job{ }……{ 中间内容不能有花括号 这个一段的正则又该怎么写?
<?php $str = 'very ordinary-looking women{regular|standard}wired phenomenon in the job{et|etplace}but in most of'; $patten = '/\}([^{]+)\{/i'; preg_match_all($patten,$str,$matches); print_r($matches);
$STR = 'very ordinary-looking women{regular|standard}wired phenomenon in the job{et|etplace}but in most of'; preg_match_all('/\{[a-z\s|]+\}/isU', $STR, $matches); print_r($matches); /** 输出结果: Array ( [0] => Array ( [0] => {regular|standard} [1] => {et|etplace} ) ) */
还有以上
}wired phenomenon in the job{
}……{ 中间内容不能有花括号
这个一段的正则又该怎么写?
$str = 'asdfefefefefef{ordinary|normal|regular|standard}';
$patten = '/(\{[ a-z|]+\})/i';
preg_match_all($patten,$str,$matches);
print_r($matches);
$str = 'very ordinary-looking women{regular|standard}wired phenomenon in the job{et|etplace}but in most of';
$patten = '/\}([^{]+)\{/i';
preg_match_all($patten,$str,$matches);
print_r($matches);
$STR = 'very ordinary-looking women{regular|standard}wired phenomenon in the job{et|etplace}but in most of';
preg_match_all('/\{[a-z\s|]+\}/isU', $STR, $matches);
print_r($matches);
/**
输出结果:
Array ( [0] => Array ( [0] => {regular|standard} [1] => {et|etplace} ) )
*/
不是两遍。
匹配的结果保存在$matches[1]中