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

类别:.NET开发 点击:0 评论:0 推荐:


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



发件人: Chris Quirk [mailto:chrisq…(at)microsoft.com]
发送时间: 2004921 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


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



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

In C#,I can do this:

    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::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?



Yun Zheng