[英]How to make php match regex NOT matching over lines?
My code is 我的代码是
preg_replace("/([^; ]+)=>([^; ]+)/", "ec_set('$1',$2);", $input_lines);
on matching the following text 在匹配以下文本时
test=>1; test; test=>123;
asdf
test=>[[test]]
The result 结果
is outputting over-lines 正在输出超线
ec_set('test',1);; test; ec_set('test',123);; ec_set('
asdf
test',[[test]]);
How to make it 怎么做
ec_set('test',1);; test; ec_set('test',123);;
asdf
ec_set('test',[[test]]);
? ?
([^;\s]+)=>([^;\s]+)
Try this.See demo. 试试看。看演示。
https://regex101.com/r/vH0iN5/4 https://regex101.com/r/vH0iN5/4
尝试这个:
preg_replace("/([^;\\n ]+)=>([^;\\n ]+)/", "ec_set('$1',$2);", $input_lines);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.