Precaseless: Case insensitive, equivalent to I var reg:tperlregex in other languages;
BEGIN REG: = Tperlregex.create (nil); Reg.
Subject: = ' abc abc '; Reg.
RegEx: = ' abc '; Reg.
Replacement: = '; Reg. Options: = [precaseless]; The option is reg of the collection type.
ReplaceAll; ShowMessage (Reg. Subject);
Return: Freeandnil (REG);
End
Preanchored: Matches only the start of the string, equivalent to ^, but there is still a difference between Var Reg:tperlregex;
BEGIN REG: = Tperlregex.create (nil); Reg.
Subject: = ' abc abc '; Reg.
RegEx: = ' abc '; Reg.
Replacement: = '; Reg. Options: = [preanchored]; Specify: Preanchored Reg.
ReplaceAll; ShowMessage (Reg. Subject);
BACK: ABC abc Freeandnil (REG);
End
{preanchored options and ^ differences: 1, in any case, preanchored matches only the beginning of the string;
2, in the Premultiline option mode, ^ can also match the beginning of each line;
3, ^ There are other uses.
}//Predollarendonly: let $ match only the end of the string Var Reg:tperlregex;
BEGIN REG: = Tperlregex.create (nil); Reg.
Subject: = ' abc abc ' #13 #10 + ' abc abc ' #13 #10 + ' abc abc '; Reg. RegEx: = ' abc$ '; //Of course you need to have $ reg.
Replacement: = '; Reg. Options: = [predollarendonly]; Specify: Predollarendonly Reg.
ReplaceAll; ShowMessage (Reg.
Subject);
{return: ABC abc abc abc abc ABC}
Freeandnil (REG);
End
Premultiline: Multi-line matching, equivalent to M var reg:tperlregex in other languages;
BEGIN REG: = Tperlregex.create (nil); Reg.
Subject: = ' abc abc ' #13 #10 + ' abc abc ' #13 #10 + ' abc abc '; Reg.
RegEx: = ' ^abc '; Reg.
Replacement: = '; Reg. Options: = [Premultiline]; Specify: Premultiline Reg.
ReplaceAll; ShowMessage (Reg.
Subject);
{returning: ABC abc abc abc ABC}
{If not specified Premultiline will be returned: ABC abc abc, ABC abc abc ABC}
Freeandnil (REG);
End
{1, Premultiline is an extended use of ^ and $;
2. Invalid if [preanchored] or [predollarendonly] is specified. }//Presingleline: let special symbols. The ability to match newline characters (.) to match any character other than a line break
www.bianceng.cn var Reg:tperlregex;
BEGIN REG: = Tperlregex.create (nil); Reg. Subject: = ' aaa;bbb; ' #13 #10 + ' 111;222; ' #13 #10 + ' AAA;
BBB; '; Reg.
RegEx: = ';. '; Reg.
Replacement: = '; Reg. Options: = [Presingleline]; Specify: Presingleline Reg.
ReplaceAll; ShowMessage (Reg.
Subject);
{back: AAA bb-AAA BB;}
{If not specified Premultiline will return: AAA BB;
;
AAA BB;
} freeandnil (REG);
End
Preungreedy: Specified as non-greedy mode var Reg:tperlregex;
BEGIN REG: = Tperlregex.create (nil); Reg.
Subject: "Delphi" and "C++builder"; Reg.
RegEx: = '. * '; Reg.
Replacement: = '; Reg. Options: = [Preungreedy]; Specify: preungreedy {In this case, Reg. RegEx: = '. *? '; can achieve the same effect} reg.
ReplaceAll; ShowMessage (Reg. Subject); Back: and;
If Preungreedy is not specified, it will return: Freeandnil (REG);
End
Preextended: Specified as the extended mode Var Reg:tperlregex;
BEGIN REG: = Tperlregex.create (nil); Reg.
Subject: = ' Delphi c++builder '; Reg. Regex : = ' i\x20c '; \X20 is a space reg in hexadecimal notation.
Replacement: = '; Reg. Options: = [preextended]; Specify: preextended Reg.
ReplaceAll; ShowMessage (Reg. Subject);
Return: Delph ++builder Freeandnil (REG);
End
{preextended is one of the most complex options: 1, it ignores whitespace in an expression, such as: In this case the expression "I C" will not match the success;
2, blank to use the corresponding hexadecimal representation, such as using \x20 to denote space;
3. The part of the expression from # to the end of the line as a comment and is ignored;
4, if you want to use the #, need to replace with \#;
5, the standard annotation of the expression is: (? # ...) and the contents behind it are all comments, regardless of the specified preextended or not}
About option Preextra:
If special characters ^ $ () [] {} are required in an expression. ? + * | \, you need to add the escape symbol \;
By default, other characters are previously added \ will be recognized as characters themselves;
The Preextra option should be to prohibit this situation, that is, do not add before the special character;
But the test effect ... Maybe I didn't figure it out!
There are also three status options: Prenotbol, Prenoteol, Prenotempty
Reg. state: = [Prenotbol] is to let the mark start ^ void;
Reg. state: = [Prenoteol] is the $ invalid for the end of the tag;
Reg. state: = [Prenotempty] not understood!
In addition, these options can be used in combination, such as:
Reg. Options: = [Precaseless, Premultiline, Presingleline];
Reg. state: = [Prenotbol, Prenoteol];