简体   繁体   English

PHP中的Posix / Perl正则表达式

[英]Posix/Perl regex in php

I have the simple regular expression: 我有简单的正则表达式:

\{[0-9]*\}

which works fine with PHP's ereg_ functions (Posix compatible), but I need to use the preg_match_all function, which doesn't have an ereg_ equivalent. 可以与PHP的ereg_函数(与Posix兼容)一起使用,但是我需要使用preg_match_all函数,该函数没有ereg_等效项。 My expression above doesn't seem to work with preg_ (perl compatible) functions. 我上面的表达式似乎不适用于preg_(与perl兼容)函数。 How can I go about "converting" it to be perl compatible? 如何进行“转换”以使其与Perl兼容?

If im reading your regex correctly then just do this: 如果即时通讯正确阅读您的正则表达式,则只需执行以下操作:

preg_match_all('/\{\d*?\}/'...);

'/\\{\\d*?\\}/' will match an integer of any length. '/\\{\\d*?\\}/'将匹配任意长度的整数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM