[Regex]Greta不支持“Named Groups”特性

news/2024/6/17 3:08:15

微软研究院出品的Gretahttp://research.microsoft.com/projects/greta/)是一款非常优秀的正则表达式模板类库GRETA的匹配速度比boost(http://www.boost.org)正则表达式库大约快7倍,比ATL7CATLRegExp10倍。你可以通过http://research.microsoft.com/projects/greta/regex_perf.html了解他的超快速度。

但是他并不支持“Named Groups”特性,这在dotNet Regex引擎中是提供的。

Greta花费了半天时间总是试验不出来这个特性后,只好去问了维护这个引擎的微软工程师。下面是来往信件:

 

发件人: Chris Quirk [mailto:chrisq…(at)microsoft.com]
发送时间: 2004 9 21 2:59
收件人: Yun Zheng; Ashish Aggarwal
主题: RE: greta gripe:for groupname syntax

Greta doesn’t support named groups; instead, it uses the more standard approach of numbering them.

 

So you should check your regex to

          "^(//w+):(//w+)"

Then you access the first group as capture number 1 and the second as capture number 2, as in Perl, etc.

 

As far as I know, named captures are a peculiarity of the .NET Regex engine.

 


From: Yun Zheng
Sent: Sunday, September 19, 2004 9:27 PM
To: Ashish Aggarwal; Chris Quirk
Subject: greta gripe:for groupname syntax

  

Hi!

I'm using greta now.It's very perfect,but I have a question:

In C#,I can do this:

[C#]
    Regex r = new Regex("^(?//w+):(?//w+)");
    Match m = r.Match("Section1:119900");

But, in VC7+greta-2[1].6.4,I run this codes: 

std::string strDest("Section1:119900");
    regex::rpattern pat("^(?//w+):(?//w+)",           
           regex::NOCASE|regex::GLOBAL|regex::EXTENDED);
    regex::match_results::backref_type br 
           = pat.match( strDest, results );

when run to construct rpattern,I get bad_regexpr( "bad extension sequence" ) exception.

 

How does Greta support groupname syntax?

 

Thanks!

Yun Zheng 

 





http://www.niftyadmin.cn/n/3648867.html

相关文章

盖茨比乔布斯_在盖茨比中使用React Hooks

盖茨比乔布斯JavaScript treats functions as first-class citizens. And we can see this in React now more than ever with the introduction of Hooks in version 16.8. They allow for state manipulation and side-effects on functional components. JavaScript将函数视…

android热修复——自己做个热修复

类的加载机制 需要注意的地方 1.每次生成之后一定要测试;2.尽量的不要分包,不要分多个dex3.混淆的时候,设计到NDK AndFix.java 不要混淆4.生成包之后一般会加固什么的,这个时候生成的差分包,一定要在之前去生成。5.…

Android系统权限配置详解

Android 权限控制代码分析 前在文章介绍过android系统管理层次:http://blog.csdn.net/andyhuabing/article/details/7030212 ,这里就核心代码分析一下 android系统充分利用了linux的用户权限管理方法,所以如果需要移植到其它系统&#xff0c…

自己动手搭建数据库框架

首先IDaoSupport接口&#xff0c;有查询&#xff0c;插入单条数据&#xff0c;批量插入&#xff0c;删除&#xff0c;更新 public interface IDaoSupport<T> {void init(SQLiteDatabase sqLiteDatabase, Class<T> clazz);// 插入数据public long insert(T t);// 批…

关于软件的架构设计

好的开始相当于成功一半 开始之初的架构设计决定着软件产品的生死存亡。“好的开始相当于成功一半”。 开始的架构设计也是最难的&#xff0c;需要调研同类产品的情况以及技术特征&#xff0c;了解当前世界上对这种产品所能提供的理论支持和技术平台支持。再结合自己项目的特点…

javascript递归_通过JavaScript了解递归和记忆

javascript递归In this article, you’re going to learn how to use recursive programming, what it is, and how to optimize it for use in algorithms. We’ll be using JavaScript as our programming language of choice to understand the concept of recursion. 在本文…

[C#][正则表达式]寻找匹配的Groups的几种方法

寻找匹配的Groups的几种方法示例&#xff1a;// // 两种大方法: // MatchCollection<->Matches // Match<->Match方式 // // 第一大种&#xff1a; MatchCollection mMCollection oRegex.Matches(strHTMLContent); if(mMCollection.Count > 1) { forea…

Apollo Boost简介

With as much as we’ve gone over creating APIs with GraphQL and Prisma in previous articles, we’ve never actually applied our custom backend to a client-side app. In this article, you’ll learn how to let your user interact with your backend through queri…