Examples

Intro ] Date And Time ] Date And Time.jsp.code ]
Directory Listing ] Directory Listing.jsp.code ] File Paths ]
Forms-Get ] Forms-Post ] Forms With Code ]
Header And Cookies ] Header And Cookies.jsp.code ] Parameter Separator Delimiter Correct ]
Parameter Separator Delimiter Wrong ] [ Regular Expressions ] Request Parameters ]
Request Parameters.jsp.code ] Top Rated Music.xml ] UserBean.java.code ]
XML Reader ] XML Reader.jsp.code ] XML Reader Methods ]
XML Reader Methods.jsp.code ] albums.xml ]

Basic Valid Pages ] [ Cookie Test ] [ Database ] [ Dynamic Layout ] [ Layout ] [ User Log On ]

Enter Regular Expression

Enter Input String

Case Insensitive Canonical Equivalence . Matches Line Terminators

Examples

Submit Regular Expression Input String

foo foo the foo when you foo

[bcr]at cats chase rats, bats fly

[^bcr]at cats chase rats, bats fly and wear hats

[a-f]at cats chase rats, bats fly and wear hats

[0-4[6-8]] 2 7 9 5 3 0

[0-9&&[345]] 2 7 9 5 3 0

[0-9&&[^345]] 2 7 9 5 3 0

a? ababaaaab

a* ababaaaab

a+ ababaaaab

a{3} ababaaaab

a{3,} ababaaaaaa

a{3,5} ababaaaaaa

(dog){3} dogdogdogdogdogdog

.*foo xfooxxxxxxfoo

.*?foo xfooxxxxxxfoo

.*+foo xfooxxxxxxfoo

(..)\1 abab ccc cdcd

^piggy$ piggy

\bpig\b piggy eat pig

Meta Characters

( ) Define Capturing Groups
Allows a group of characters to be treated as a single unit
Capturing Groups are numbered according to the number of opening parentheses left to right.
[ ] Defines character class
\n Back reference captured group n
Escape Character when used by itself \
| OR
&& Intersection Operator
. Any single character
May or may not match line terminators
, Bound number of matches
Quantifiers
? Match once or not at all
Also append to quantifier to create Reluctant Quantifier
* Match zero or more times
+ Match one or more times
Also append to quantifier to create Possessive Quantifier
{n} Match pattern n times
Boundary Matchers
^ Match beginning of a line
Negation when used in character class
$ Match end of a line
\b Word boundary
\B Non-word boundary
\A Beginning of input
\G End of previous match
\Z End of input but before final terminator, if any
\z End of input
Predefined Character Ranges
\d A single digit [0-9]
\D A single non-digit [^0-9]
\s A single whitespace character [ \t\n\x0B\f\r]
\S A single non-whitespace character [^\s]
\w A single word character [a-zA-Z_0-9]
\W A single non-word character [^\w]
Embedded Flag Expressions
(?i) Case Insensitive
(?x) Comments - whitespace and # until end of line ignored
(?m) Multi line
(?s) Dot "." matches line terminators too
(?u) Unicode
(?d) Unix lines
Precede meta character with backslash to have it be treated like an ordinary character
Or enclose it within \Q and \E (start quote, end quote)

Notes

  • Index ranges are inclusive of the beginning index and exclusive of the end index.
 

by: Keith A. Pray
Last Modified: April 15, 2009 11:27 PM
© 2009 - 1975 Keith A. Pray.
All rights reserved.