Delphi Regular Expression Syntax (7): Match escape character
The meaning of the//? is to match 0-1 times, what if a match is needed? var reg:tperlregex; begin Reg: = tperlregex.create (nil' How are you? ' OK! ') Reg. RegEx ' \?|! ' ///Gar use of \ "' //return: How are you, okay? Freeandnil (REG); End;
//random escape symbols \ Sometimes yes, but sometimes problems, better not to mess with var reg:tperlregex; begin Reg: = tperlregex.create (nil' How are you? ' OK! ') Reg. RegEx ' \?| \!| \ Good '//Give unnecessary! "and" good "added \ In this example also normal "//return: You're okay . Freeandnil (REG); End; {There would have been an option [Preextra] to prohibit the use of chaos, but the effect is not good}
Special character list in regular expressions:
Special characters |
Meaning in regular expressions |
Match the character itself |
^ |
Matches the beginning of a string, or does not match the contents of [] |
\^ |
$ |
Match the end of a string |
\$ |
and |
Marker sub-expression |
\ (and \) |
and |
Expressions that match "multi-character" |
\[and \] |
and |
Symbol for number of matches |
\{and \} |
. |
Match all characters except line break |
\. |
? |
Match 0 or 1 times |
\? |
+ |
Match at least 1 times |
\+ |
* |
Match 0 or more times |
\* |
| |
Or |
\| |
\ |
Escape symbol itself |
\\ |
Delphi Regular Expression Syntax (7): Match escape character