现在用
preg_match("/^(\d+(\\.\\d+)?)([+*\/\-])(\d+(\\.\\d+)?)$/", $str, $matches);
能匹配到1+1的形式
如果1+1+1就匹配不可像google 你输入 1+1+1+1+1+1=? 他都能得出结果 这个程序该怎么写呢?怎么匹配?
preg_match("/^(\d+(\\.\\d+)?)([+*\/\-])(\d+(\\.\\d+)?)$/", $str, $matches);
能匹配到1+1的形式
如果1+1+1就匹配不可像google 你输入 1+1+1+1+1+1=? 他都能得出结果 这个程序该怎么写呢?怎么匹配?
使用:$str='fdsfsaf1+1+1fdsafsaf';
preg_match_all("/1(\+1)+/", $str, $matches);
print_r($matches[0]);//匹配结果为:Array ( [0] => 1+1+1 )
即可