Difference between revisions of "IDE regular expressions"

From Free Pascal wiki
Jump to navigationJump to search
Line 5: Line 5:
 
=== Point . ===
 
=== Point . ===
  
Matches any character. Example: 'a.c' matches 'abc', 'aBC', 'axc', 'a3c', 'a$c', etc.
+
Matches any one character. Example: 'a.c' matches 'abc', 'aBC', 'axc', 'a3c', 'a$c', etc.
  
 
=== Round brackets ( ) ===
 
=== Round brackets ( ) ===

Revision as of 21:39, 1 May 2006

Normal regular expression

They are pretty similar to Perl regular expression syntax.

Point .

Matches any one character. Example: 'a.c' matches 'abc', 'aBC', 'axc', 'a3c', 'a$c', etc.

Round brackets ( )

Useful to bound expressions. 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'