什么是PCRE兼容语法? C#PCRE是否兼容? [英] What is PCRE-compatible syntax? And is C# PCRE-compatible?

查看:105
本文介绍了什么是PCRE兼容语法? C#PCRE是否兼容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是PCRE兼容语法? C#PCRE是否兼容?
从维基百科我发现了这一点:

What is PCRE-compatible syntax? And is C# PCRE-compatible? From wikipedia I found this:


Perl兼容正则表达式(PCRE)是一个正则表达式C
库的启发由Philip Hazel编写的Perl
编程语言中的正则表达式功能开始,从1997年夏季开始。1997年。PCRE的语法比POSIX正则表达式和许多经典正则$都强大和灵活。 b $ b表达库。该名称具有误导性,因为PCRE和Perl
各自具有彼此不共享的功能。

Perl Compatible Regular Expressions (PCRE) is a regular expression C library inspired by the regular expression capabilities in the Perl programming language, written by Philip Hazel, starting in summer 1997. PCRE's syntax is much more powerful and flexible than either of the POSIX regular expression flavors and many classic regular expression libraries. The name is misleading, because PCRE and Perl each have capabilities not shared by the other.

来源

推荐答案

C#正则表达式与PCRE正则共享一些语法。大多数功能重叠,但是两个库都保留了自己的详细信息:

C# regexes share some syntax with PCRE regexes. Most of the features overlap but both libraries keep their own specifics:

几个示例:

PCRE


  • 支持递归

  • 支持回溯控制动词

  • 支持诸如(?(DEFINE)...)

  • 支持更多选项

  • 提供DFA解析模式

  • 支持部分匹配

  • 支持 \K

  • 支持 X ++ 速记语法(相当于(?> X +)

  • Supports recursion
  • Supports backtrack control verbs
  • Supports constructs like (?(DEFINE) ... )
  • Supports more options
  • Offers a DFA parsing mode
  • Supports partial matches
  • Supports \K
  • Supports X++ shorthand syntax (equivalent of (?>X+))

.NET


  • 支持捕获堆栈和重复的命名组

  • 支持平衡组

  • 支持可变长度的向后看

此列表并不详尽。您可以在此页面和同级页面上比较这两种口味。

This list is not exhaustive. You can compare both flavours on this page and the sibling pages.

鉴于两者之间的差异,我希望能够使用.NET中的PCRE正则表达式,并且最近启动了 PCRE.NET ,这是一个包装项目。它尚未完成,但开始可用。

Given the differences, I wanted to be able to use PCRE regexes from .NET and recently started PCRE.NET, which is a wrapper project. It's not finished yet but is starting to be usable.

这篇关于什么是PCRE兼容语法? C#PCRE是否兼容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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