[英]Using Regex to replace string in Delphi
From Official documentation of RegularExpressions , the output should be NUMabcabc
. 从RegularExpressions的官方文档中 ,输出应为
NUMabcabc
。 But it is not. 但事实并非如此。 I wonder what is wrong ?
我想知道出了什么问题?
program Project128;
{$APPTYPE CONSOLE}
uses RegularExpressions;
var Regex: TRegEx;
begin
Regex := TRegEx.Create('{[0-9]}{[a-c]*}');
WriteLn(Regex.Replace('3abcabc', 'NUM\1'));
ReadLn;
end.
You've got the wrong docs. 你的文档错了。 The docs you reference are for the regex flavour used by IDE search and replace.
您引用的文档是IDE搜索和替换使用的正则表达式。 That flavour of regex is just used by the IDE.
IDE正在使用这种正则表达式。 The flavour used by the
RegularExpressions
unit is PCRE, which is quite different and is documented here . RegularExpressions
单元使用的风格是PCRE,这是完全不同的,并在此处记录 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.