`
阿尔萨斯
  • 浏览: 4147763 次
社区版块
存档分类
最新评论

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

 
阅读更多
<iframe align="center" marginwidth="0" marginheight="0" src="http://www.zealware.com/csdnblog336280.html" frameborder="0" width="336" scrolling="no" height="280"></iframe>

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

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

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

发件人: Chris Quirk [mailto:chrisq…(at)microsoft.com]
发送时间: <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /><chsdate w:st="on" isrocdate="False" islunardate="False" day="21" month="9" year="2004">2004<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: 'Times New Roman'"><span lang="EN-US">年</span></span>9<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: 'Times New Roman'"><span lang="EN-US">月</span></span>21<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-ascii-font-family: Arial; mso-hansi-font-family: 'Times New Roman'"><span lang="EN-US">日</span></span></chsdate> 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 <time w:st="on" minute="27" hour="21">9:27 PM</time>
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




分享到:
评论

相关推荐

    regex.h regex.cpp

    linux下的C语言正则表达式头文件和源文件: regex.h regex.cpp

    Regex Quick Syntax Reference--2018

    What You Will Learn Formulate an expression Work with arbitrary char classes, ... Handle substring extraction from regex using Perl 6 capture groups, capture substrings, and reuse substrings

    易语言源码RegEx.rar

    易语言源码RegEx.rar 易语言源码RegEx.rar 易语言源码RegEx.rar 易语言源码RegEx.rar 易语言源码RegEx.rar 易语言源码RegEx.rar

    Greta 2.6.4 正则表达式库

    已编译好的微软Greta 2.6.4 正则表达式库。 里面有5个文件(4个h,1个lib) 下载来直接放到要使用正则的项目里就行了。 #include #include "regexpr2.h" using namespace std; using namespace regex; #pragma ...

    Regex Expression(正则表达式)

    Regular expression 具有可以表达出难以描述、複杂、但是却有特殊规则的字串的功能,所以许多的 UNIX 工具程式都有支援 Regular expression 的功能。例如 ex 、 vi 、 sed 、 awk 、 grep ...这里有文件Regex.h,Regex.c

    正则表达式支持库2.0#0版(静态版)

    易语言RegEx_static.lib支持库中文名为易语言正则表达式支持库,本易语言支持库实现了对正则表达式(Regular Expression)的支持。注意,本支持库中的所有命令均为高级命令,要求使用者具有一定的正则表达式知识基础...

    mingw下64位的regex.dll

    64位的regex.dll 在mingw环境下编译成的,大家可以使用

    正则表达式 测试 工具Regex Testor

    界面功能提供regex语法支持。(暂时可以通过导入附件RegexSystax.ini到CustomPatternInfo.ini中) 4.意见反馈 a.请将您的宝贵意见反馈到 FieryRed_2012@163.com 附件: Readme.txt Readme_1.jpg Readme_2.jpg ...

    C++正则表达式-regex类(不依赖其他库)

    提取了boost::regex里边的几个正则表达式匹配搜索接口,打包成DLL,以在不依赖于boost的情况下独立编译运行

    GNU regex windows编译

    GNU regex windows编译 regex2dll 替换成源码。可直接添加进工程使用

    regex

    regex最简单使用的工具

    Regex Workbench超好用的正则工具

    Regex Workbench超好用的正则工具,不知道为什么现在下载不到了,现提供下载,支持最新的dotnet,真的好用。

    regex正则工具,可复制代码

    RegexTester-正则工具,可复制代码,非常好用 1.功能简介 支持仅使用表达式里的选中部分进行匹配 自动加载上次关闭前运行的最后一组数据 支持树形,表格, 文本等三种结果查看方式 支持快捷键操作(F5运行, F4切换查询...

    C++Regex正则表达式

    C++Regex正则表达式

    Regex正则表达式

    Regex

    TestRegex_regex_C#_

    Simple application for test string regex

    正则表达式安全漏洞测试工具SDL Regex Fuzzer

    免费工具 SDL Regex Fuzzer 用以帮助程序员测试他们的正则表达式是否存在 ...SDL Regex Fuzzer支持的操作系统: Windows 7;Windows Server 2003;Windows Server 2008;Windows Server 2008 R2;Windows Vista;Windows XP

    greta正则表达式模板类库

    本文摘要翻译了几篇文章的内容,简单介绍 ATL CAtlRegExp,GRETA,Boost::regex 等正则表达式库,这些表达式库使我们可以方便地利用正则库的巨大威力,给我们的工作提供了便利。

    Regex Tester

    一个.Net下的测试正则表达式 工具Regex Tester,打开压缩包,直接运行RegexTester.exe

    regex 正则软件

    regex 正则软件regex 正则软件regex 正则软件regex 正则软件regex 正则软件 让你很好的上手测试正则表达式

Global site tag (gtag.js) - Google Analytics