Python 中使用了哪种正则表达式风格? [英] Which Regular Expression flavour is used in Python?

查看:62
本文介绍了Python 中使用了哪种正则表达式风格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将哪个 RegEx-Flavour 用于 Python?它是 PCRE、Perl 兼容还是 ICU 或其他什么?

I want to which RegEx-Flavour is used for Python? Is it PCRE, Perl compatible or is it ICU or something else?

推荐答案

它与 Perl 的足够兼容,这意味着大多数 Perl 表达式无需修改即可工作.它旨在与 Perl 兼容,但当然也存在一些细微差别.

It's compatible enough w/ Perl, meaning most Perl expressions will work unmodified. It aims to be Perl compatible but, of course, there are some minor differences.

从技术上讲,它使用自己的正则表达式风格.例如,在其他实现采用该语法之前很久,Python 正则表达式中就提供了命名组.它还支持开箱即用的 Unicode.如今,大多数 Python 扩展都在其他地方得到支持.见 http://docs.python.org/library/re.html

It, technically, uses its own flavor of regular expressions. For instance, named groups were offered in Python regex long-before other implementations adopted the syntax. It also supports Unicode out of the box. Most Python extensions are supported elsewhere these days. See http://docs.python.org/library/re.html

这篇关于Python 中使用了哪种正则表达式风格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆