Regular Expression Tester

The Cascading Style Sheet has not loaded, so this page will not display properly

String
Regular Expression  /    Attributes Replacement  
String.match(RegExp)   String.search(RegExp)   RegExp.lastMatch   RegExp.lastParen  
RegExp.input  
RegExp.leftContext   RegExp.rightContext  
RegExp.$1   RegExp.$2   RegExp.$3   RegExp.$4   RegExp.$5  
RegExp.$6   RegExp.$7   RegExp.$8   RegExp.$9  
After Replacement  
Enter test string and regular expression, then click Test to view operation on string

Guidance

Regular Expressions

Character set: [ABC] = any character listed; [^abc] = not any character listed; [\w\W] = any character including newline; [A-Z] = range of characters

Escaped characters: \f = formfeed; \n = newline; \r = carriage return; \t = tab; \v = vertical tab; also those in regular expression syntax \/ \. \? \* \+ \{ \} \^ \$ \( \) \|

Metacharacters: \b = word boundary; \B = not word boundary; \d = digit = [0-9]; \D = not digit; \s = single space; \S = not space; \w = letter, digit or underscore = [A-Za-z0-9_]; \W = not letter, digit or underscore; . = any character except newline

Counts of previous character: ? = 0 or 1; * = 0 or more; + = 1 or more; {n} = n times; {n,} = n or more times; {n,m} = at least n, at most m times

Position metacharacters: ^ = beginning of string or line; $ = end of string or line

Grouping: () = groups content, may be nested and sets $n; | = alternatives

Greediness: regular expressions match as much as they can in the string while the entire expression still matches

Attributes

Attributes: g = global, i = case insensitive, m = multi-line