我有以下字符串,并且我尝试使用正则表达式preg_replace
对与12c
版本号不匹配的任何内容执行。
你可以看到工作比赛
我正在使用的表达式匹配12c
字符串格式,但是我似乎无法弄清楚如何或者是否有可能反转/否定正则表达式匹配项,而不是替换12c
,替换所有内容,而是12c
只替换12c的11g等由该preg_match
函数返回。
代码:
preg_match('/(\s[0-9]{2}[a-z]{1}\s)/', '', 'Oracle Database 12c Enterprise Edition Release 12.1.0.0.2 - 64bit Production with the Partitioning, OLAP, Data Mining and Real Application Testing option');
图案:
/(\s[0-9]{2}[a-z]{1}\s)/
细绳:
Oracle Database 12c Enterprise Edition Release 12.1.0.0.2 - 64bit Production with the Partitioning, OLAP, Data Mining and Real Application Testing option
如果我理解正确,那么您希望获得与模式匹配的文本:
if (preg_match('/([0-9]{2}[a-z]{1})/', 'Oracle Database 12c Enterprise Edition Release 12.1.0.0.2 - 64bit Production with the Partitioning, OLAP, Data Mining and Real Application Testing option', $m))
echo $m[1]; // 12c
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句