> 'find'); var: '_find' = (string_replace: $find, -find='\\\\', -replace='\\'); var: 'result' = (string_findregexp: $text, -find=$_find); else: ($action >> 'replace'); var: '_find' = (string_replace: $find, -find='\\\\', -replace='\\'); var: '_replace' = (string_replace: $replace, -find='\\\\', -replace='\\'); var: 'result' = (string_replaceregexp: $text, -find=$_find, -replace=$_replace); /if; ?> Tip of the Week - Regular Expression Explorer

Tip of the Week - Regular Expression Explorer

This page allows you to try out regular expressions. It is a companion to the tips of the week Regular Expressions (Basics), Regular Expressions (Find/Replace), and Regular Expressions (Text Cleanup)

Scroll down to see the LDML code for the specified find or find/replace, the results, and a regular expression quick reference.

[if: $result === null] [else: $result === (array)] [else: $result->(isa: 'array')] [else: $result == ''] [else] [/if]
Text
Find
Replace
   

Results No Results
Results Empty Array
Results Array ([$result->size] elements)
 
Results Empty String
Results String ([$result->size] chars)
 

LDML
Code
[if: $action >> 'find'] [else: $action >> 'replace'] [/if]

Regular Expression Reference

[noprocess][String_ReplaceRegExp][/noprocess] in LDML Reference

[noprocess][String_FindRegExp][/noprocess] in LDML Reference

Matching Symbols

[noprocess]
a-z A-Z 0-9 - Alphanumeric characters match the specified character.
. - Period matches any single character.
^ - Circumflex matches the beginning of a line.
$ - Dollar sign matches the end of a line.
\\... - A backslash escapes the next character. \\\\ represents a backslash.
[...] - Square brackets create a character class matching any character included inside.
[^...] - With a carat, any character other than those included inside is matched.
[a-z] - A range of characters can be specified.
\t - A tab character.
\r - A return character.
\n - A new-line character.
\" - A double quote.
\' - A single quote.
\\w - Matches any alphanumeric character or an underscore.
\\W - Matches any non-alphanumeric character.
\\s - Matches a whitespace character (space, tab, return, etc.).
\\S - Matches a non-whitespace character.
\\d - Matches a numeric digit.
\\D - Matches any non-numeric character.
[/noprocess]

Combination Symbols

[noprocess]
| - Alternation. Matches either the character before or the character after the symbol.
( ) - Grouping. Defines a named group for output. Nine pairs of parentheses can be defined.
* - Asterisk matches 0 or more repetitions of the preceding character.
*? - Matches the shortest possible number of repetitions of the preceding character.
+ - Plus sign matches 1 or more repetitions of the preceding character.
? - Question mark matches 0 or 1 repetitions of the preceding character.
{n} - Matches n repetitions of the preceding character.
{n,} - Matches at least n repetitions of the preceding character.
{n,m} - Matches at least n, but no more than m repetitions of the preceding character.
[/noprocess]

Replacement Symbols

[noprocess]
\\1 ... \\9 - An escaped number substitutes in the specified group (defined by parentheses) from the source.
[/noprocess]
The Source Code for this page is available.
Copyright 2005 by OmniPilot Software, Inc.