REGEX从PHP到Python是否有所不同 [英] Does REGEX differ from PHP to Python
问题描述
我发现了这篇文章: Python Regex vs PHP Regex ,但实际上我没有获取Python的REGEX语法是否与PHP的REGEX语法匹配.
I found this post: Python Regex vs PHP Regex but I actually did not get if Python's REGEX syntax matches PHP's REGEX syntax.
我开始将我的一些旧PHP代码转换为python(由于g的appengine等),现在我想通过简单的复制&粘贴.
I started to convert some of my old PHP code to python (due to g's appengine etc.), and now I would like to know whether the regex is 100% convertable, by simple copy & paste.
致谢
推荐答案
Python使用类似于Perl语法的语法,PHP使用 Perl兼容的正则表达式语法,因此它应该几乎相同.了解可能的差异.
Python uses a syntax similar to the Perl syntax and PHP uses the Perl Compatible Regular Expressions syntax, so it should be nearly the same. Read about the possible differences.
唯一真正的区别是,在PHP中,表达式必须包含在 定界符 .
The only real difference is that in PHP, the expression must be enclosed in delimiters.
这篇关于REGEX从PHP到Python是否有所不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!