Regular Expressions

From TekiWiki

Jump to: navigation, search

This whole wiki has now moved to http://www.springboardsolutions.com/wiki

Go to this page Regular Expressions

Line 4: Line 4:
Regular expression information: [http://www.homemarketeer.com/sbs/regexp.htm Regular Expression Information]
Regular expression information: [http://www.homemarketeer.com/sbs/regexp.htm Regular Expression Information]
 +
 +
 +
A Regular Expression is a search string and optionally a replacement string:
 +
 +
==Search String Rules==
 +
 +
^ - matches start of line
 +
 +
$ - matches end of line
 +
 +
. - matches any single character
 +
 +
[abc] - matches single a or b or c
 +
 +
[^abc] - matches a character other than a or b or c
 +
 +
(ab|cd) - matches ab or cd
 +
 +
* - matches zero or any number of the previous character/expression
 +
 +
+ - matches one or more of the previous character/expression
 +
 +
? - matches zero or one of the previous character/expression
 +
 +
{3} - matches three of the previous character/expression
 +
 +
{3,} - matches at least three of the previous character/expression
 +
 +
{3,5} - matches between three and five of the previous character/expression
 +
 +
\n - matches New Line character
 +
 +
\t - matches Tab character
 +
 +
\f - matches Form Feed character
 +
 +
\r - matches Carriage Return character
 +
 +
\v - matches Vertical Tab character
 +
 +
\d - matches any digit
 +
 +
\D - matches a character other than a digit
 +
 +
\w - matches any letter, digit or underscore (_)
 +
 +
\W - matches a character other than a letter, digit or underscore (_)
 +
 +
\s - matches any white space
 +
 +
\S - matches a character other than a white space
 +
 +
\b - matches a word boundary
 +
 +
\B - matches a character other than a word boundary
 +
 +
\. - matches an actual dot (works for all meta characters - including \)
 +
 +
Other characters match with themselves
 +
 +
==Replacement String Rules==
 +
 +
& - replace with entire matched string
 +
 +
$1 ... $9 - replace with first ... ninth matched bracketed () expression

Revision as of 19:15, 6 June 2013

Personal tools