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

微软研究院出品的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 

 



Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=112710


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值