Regular Expression (regex aka RE) Demo

Please enter your pattern (as a regular expression) and data; this program will show below if the data matches the pattern. You can select a common pattern to get started. This page uses JavaScript regexes; please note that since regex notation varies by platform. For example, "$" means "end of string" in JavaScript, POSIX ERE, and Go, but it does not mean end of string in Python (use "\Z" instead) nor in Ruby (use "\z" instead).

Common pattern:

Pattern:

Data:



You need to enable JavaScript for this to work.



Some key parts of the JavaScript regex language:

  1. Letters and digits stand for themselves, a “.” matches any one character (except newline or carriage return), “[...]” lists a set of acceptable characters (these are all atoms).
  2. An atom may be followed by a duplication marker, creating a piece: “*” means match 0 or more of the previous atom, “+” means match 1 or more of the previous atom, “?” means the previous atom is optional, “{n,m}” means n through m of the previous atom.
  3. “(...)” groups a sequence of pieces into one atom.
  4. “|” separates alternative sequences of pieces.

When using regular expressions as a filter, be sure that it begins with ^ (match data beginning) and ends with $ (match data ending). Beware: the | has lower precedence.

Regexper.com provides a delightful visualization of regular expressions.

You can get a similar text-based C program regex.c if you want to try out POSIX EREs instead of JavaScript regular expressions (they have much in common but are not identical).

(C) Copyright 2012- David A. Wheeler.