我想解析这个
(adv) much (thanks)
我想消除单词和括号(adv)但不是(谢谢)
条件是: 内括号,括号内的字长为1-5个字符
我在PHP中使用preg_match
答案 0 :(得分:2)
$matches = NULL;
preg_match("/\([^\)]{1,5}\)/", "(adv) much (thanks)", $matches);
var_export($matches);
array (
0 => '(adv)',
)
答案 1 :(得分:2)
$str = '(adv) much (thanks)';
$str = preg_replace('/\(\w{1,5}\) ?/', '', $str);