Wikia

Delphi Programming

Regular Expressions

2,918pages on
this wiki
Talk0

The Delphi IDE Editor has a checkbox for Regular Expressions in the Find, Replace, and Find in Files menus. They are documented in the Delphi 5, 6 and 7 help. There are two flavors: Regular Expressions and Brief Regular Expressions (if you have Brief keystroke mappings).

Regular Expressions Edit

^Beginning of Line
$End of Line
.Any one character
*Zero or more of Previous character (as many as possible)
+One or more of Previous character (as many as possible)
[ ]Any One of this set of characters
[^ ]Any One character NOT in this set
[a-z]Hyphen indicates a range of characters
{ }Group expressions
\Escape any one of the characters above

Brief Regular Expressions<?php echo "";?> (only in Brief keystroke mappings) Edit

<Beginning of Line
%Beginning of Line
$End of Line
>End of Line
?Any one character
@Zero or more of Previous character (as many as possible)
+One or more of Previous character (as many as possible)
|Logical OR
^Logical NOT
[ ]Any One character in this set
[^ ]Any One character NOT in this set
[a-z]Hyphen indicates a range of characters
{ }Group expressions
\Escape one of the characters above

Undocumented features of Delphi Regular Expressions Edit

Case Sensitive Checkbox

Normally, all regular expressions are case sensitive. But Delphi Regular Expressions are not unless you check the Case Sensitive box in the Find Dialog.

Search String Expressions

|Logical OR from Brief Regular Expressions also works in Regular Expressions

Replace String Expressions

\0 .. \9Insert text from Group (0-9) in the Found Text
\nInsert a Newline
\tInsert a Tab

The whole point of grouping characters inside { } is to let you put them back. For example Find: {Version} +{[0-9]+\.[0-9][0-9]} Replace: \0 Alpha \1 will find the text Version 1.23 and replace it with Version Alpha 1.23 regardless of the particular digits. The first group finds the word Version. Then one or more spaces are required. Finally the second group finds one or more digits, a period, then two digits.

Around Wikia's network

Random Wiki