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)
- Insert your regular expression pattern. For example: #<a href="([^"])">(.*?)</a>#i
- 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); - Select source (Text or URL)
- Test your expression
- 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
- \ - special characters to literal and literal characters to special
- ? - 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
- ^ - 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
- (?: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
- \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
