Regex Test

Test your regular expressions online - simple and fast!
This tools will help you to test your regular expressions real quick.

How it works (Basic usage)

  1. Insert your regular expression pattern. For example: #<a href="([^"])">(.*?)</a>#i
  2. Choose output format (Array,JSON,Serialize).
    Tip: Choose JSON or serialize if you want to directly use this data in php or javascript.

    Example in php with serialize:

    $data = 'copied data'; $data = unserialize($data);

    Example in php with JSON decode:

    $data = 'copied data'; $data = json_decode($data);

    Example in Javascript with JSON:

    var json = 'copied data'; var data = JSON.parse(json);
  3. Select source (Text or URL)
  4. Test your expression
  5. Copy data if needed







Examples

HTML Tags

Match a specific HTML Tag:
<tagname\b[^>]*>(.*?)</tagname>

Match any HTML Tag:
<([A-Z][A-Z0-9]*)\b[^>]*>(.*?)</\1>

Regex Syntax

Flags

If specified, flags can have any combination of the following values:

  • g - global match
  • i - ignore case
  • m - match over multiple lines
Escaping
  • \ - special characters to literal and literal characters to special
Quantifiers
  • ? - matches zero or one times
  • * - matches zero or more times
  • + - matches one or more times
  • {n} - matches n times
  • {n, m} - matches at least n times, but not more than m times
Anchors
  • ^ - matches at the start of the line
  • $ - matches at the end of the line
  • \b - matches at the beginning or the end of a word
Delimiter
  • (?:x) - matches x not remember the match
  • x(?=y) - matches x only if x is followed by y
  • x(?!y) - matches x only if x is not followed by y
Character Escapes
  • \s - matches whitespace
  • \S - matches anything but a whitespace
  • \f - matches a form-feed
  • \n - matches a linefeed
  • \r - matches a carriage return
  • \t - matches a horizontal tab
  • \v - matches vertical tab
  • \d - matches any digit
  • \D - matches anything except digit
  • \w - matches any alphanumeric character including the underscore. Equivalent to [A-Za-z0-9_]
  • \W - matches any non-word character. Equivalent to [^A-Za-z0-9_]
  • . - matches any character except a newline