使用preg_replace删除所有低于15的数字

时间:2016-03-04 17:09:15

标签: php regex preg-replace

我试图删除低于' 15'使用preg_replace例如: $string = '1 20 5 16 11 15 14'; 我希望preg_replace之后的输出为20 16 15 怎么做:))

2 个答案:

答案 0 :(得分:1)

使用此模式

switch0.setOn(true, animated:true)

解释

\s*\b\d\b|\b1[01234]\b

答案 1 :(得分:0)

替换范围从09或范围从1014

的所有数字
$string = '1 20 5 16 11 15 14';
var_dump(preg_replace("/\b([0-9]{1}|1[0-4]{1})\b/", "", $string));

// the output: ' 20  16  15 '