Difference between revisions of "IDE regular expressions"
From Free Pascal wiki
Jump to navigationJump to searchLine 30: | Line 30: | ||
== Search and Replace with regular expressions == | == Search and Replace with regular expressions == | ||
+ | |||
+ | The find dialogs support regular expressions for finding and replacing. For example: | ||
+ | |||
+ | * Find expression: a(.*)c | ||
+ | * Replace expression: A$1C | ||
+ | * Text: 'abc aLazc' | ||
+ | |||
+ | The $1 will be replaced with the found text, that matches the first bracket. | ||
+ | |||
+ | * Result: 'AbC ALazC' |
Revision as of 11:18, 1 May 2006
Normal regular expression
They are pretty similar to Perl regular expression syntax.
Point .
Matches any character. Example: 'a.c' matches 'abc', 'aBC', 'axc', 'a3c', 'a$c', etc.
Round brackets ( )
Useful to bound expressins. For example: (abc)+ matches 'abc' or 'abcabc' or 'abcabcabc' etc.
Simple Syntax
Some IDE dialogs provide a checkbox to enable 'simple syntax'. These regular expressions are shorter for common file name filters.
Technically it does this:
The following characters are replaced with . -> \. * -> .* ? -> . , -> | ; -> | Finally enclose by ^( )$
Search and Replace with regular expressions
The find dialogs support regular expressions for finding and replacing. For example:
- Find expression: a(.*)c
- Replace expression: A$1C
- Text: 'abc aLazc'
The $1 will be replaced with the found text, that matches the first bracket.
- Result: 'AbC ALazC'