[英]Regex fails on new line
I have an regex expresion which is like this 我有这样的正则表达式
preg_match("/^\\s*(insert|delete|update|replace|create|drop|alter|use) /i",$query)
This is a part of a pretty old function which is responsible for allmost all of the transactions on our site that we maintain (it is like 8 years old at min...) 这是一个相当老的功能的一部分,该功能负责维护我们维护的我们网站上的所有交易(至少8年之久...)
Imagine my suprice when this query failed te test on this regex.... 假设我的suprice在此正则表达式上的查询测试失败时...
"DELETE
FROM KursSmer
WHERE IDKurs = '523' AND
IDSmer = '50' AND
IDSkolskaGodina = '1' AND
JeObavezan = '0'"
It took me about 1h to get the nasty fella... but i did it... there was a \\n line element on the end of the first row just next to DELETE word... like DELETE\\n
我花了大约1个小时才得到令人讨厌的家伙...但是我做到了...在第一行的末尾有一个\\ n行元素,紧挨着DELETE单词...像
DELETE\\n
Now, I am left wondering if this can be corrected? 现在,我想知道这是否可以纠正?
You need m
modifier for multiple lines. 您需要多行
m
修饰符。
preg_match("/^\\s*(insert|delete|update|replace|create|drop|alter|use) /im",$query)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.