简体   繁体   English

Delphi VCL是否提供正则表达式库?

[英]Does Delphi VCL provide a regular expression library?

Is there a library in the VCL for regular expressions? VCL中是否有正则表达式的库?

If not can you recommend a good third party library. 如果没有,你能推荐一个好的第三方图书馆吗?

Starting with Delphi XE, the RTL contains support for regular expressions: 从Delphi XE开始,RTL包含对正则表达式的支持:

http://docwiki.embarcadero.com/RADStudio/en/VCL_and_RTL_Changes_for_XE http://docwiki.embarcadero.com/RADStudio/en/VCL_and_RTL_Changes_for_XE

RegularExpressions.TRegEx is the main record for the user to match and replace with regular expressions. RegularExpressions.TRegEx是用户匹配和替换正则表达式的主记录。 The members of the RegularExpressions unit make up an interface very close to the MSDN interface, ... RegularExpressions单元的成员组成一个非常接近MSDN接口的接口,...

and

RegularExpressionsCore.TPerlRegEx implements Perl-compatible regular expressions ( http://www.regular-expressions.info/pcre.html ). RegularExpressionsCore.TPerlRegEx实现了与Perl兼容的正则表达式( http://www.regular-expressions.info/pcre.html )。

Delphi does not provide a regular expression library in the VCL. Delphi不在VCL中提供正则表达式库。

There are some third party regular expression units. 有一些第三方正则表达单位。

DIRegExp DIRegExp

TRegExpr 2 (site is down 22.9.2009) TRegExpr 2 (网站已于2009年9月22 下降)

Jedi Code Library(JCL) provides a perl based regular expression. Jedi代码库(JCL)提供基于perl的正则表达式。 Download JCL from this link . 从此链接下载JCL。

After install go to installation folder/source/common and you have JclPCRE.pas and pcre.pas 安装后转到安装文件夹/ source / common,你有JclPCRE.pas和pcre.pas

请参阅TPerlRegEx下载 ),即使它只是PCRE的包装器。

There is not one "in the box", as mentioned by others. 如其他人所述,没有一个“在盒子里”。 However, we need to be careful when we say "can we have regexp in the IDE/VCL", because two different people asking for this may have two very different ideas as to which regexp they want to see supported . 但是,当我们说“我们可以在IDE / VCL中使用regexp”时,我们需要小心,因为两个不同的人要求这个可能有两个截然不同的想法, 他们希望看到支持哪个正则表达式

So whilst it might nice to have a form of regexp support "built-in" you have to be aware that this will lead to problems when people start exchanging regexp recipes (with other people not using Delphi) and can't figure out why one person's valid regexp is not a valid regexp in Delphi. 因此,虽然拥有一种“内置”的正则表达式支持可能会很好,但你必须意识到,当人们开始交换正则表达式食谱(与其他人不使用Delphi)时,这会导致问题并且无法找出原因person的有效正则表达式不是Delphi中的有效正则表达式。

So then it will be "regexp is broken in Delphi" or "why can't we have XYZ regexp support as well as the ABC flavour support?" 那么它将是“regexp在Delphi中被破坏”或“为什么我们不能拥有XYZ正则表达式支持以及ABC风味支持?”

So at the moment I'd say having the choice as to which regexp is right for you is in some ways an advantage, assuming you can find a component/library for Delphi which supports that flavour. 所以目前我认为选择哪个regexp适合你在某种程度上是一个优势,假设你可以找到支持这种风格的Delphi组件/库。 :) :)

The regular-expressions.info site also has a page specifically about Delphi support for regexp . regular-expressions.info网站还有一个专门关于Delphi支持regexp的页面

RegEx is another thing you don't have in Delphi. RegEx是Delphi中没有的另一件事。 Perhaps you try the PCRE-based Components for Delphi (didn't test it myself). 也许您尝试使用基于PCRE的Delphi组件 (没有自己测试)。

I used TRegExp (mentioned by sdu ) a few years ago but now the link seems to be dead. 我用TRegExp(由提到SDU )几年前,但现在的链接似乎是死了。 Curious... 好奇...

如果您打算使用Jedi代码库(JCL),您仍需要安装PCRE库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM