# RegEx Tester

Regular expressions (regex or regexp) are very effective for extracting information from text.
To do this, you need to search for one or more matches by a specific pattern (i.e., a specific
sequence of ASCII or unicode characters). The applications of regex are diverse, from validation
to parsing / replacing strings, transferring data to other formats and web scraping.

Just enter the regular expression below and some text to test your regular expression, or scroll down
to try one of our examples.

**Flags**

#### Results

**Matches**

### Examples to Try

Try some of the examples below to get a feel about how this RegEx Tester works. Just click on the button below for for the examples to appear in the input fields above. Play around with the regular expressions and you'll soon see what is happening.

### About Regular Expressions

Learn more about Regex by using the cheat sheet below, with explanations for each character that is used in regular expressions.

Special Characters | |

`^` | Matches the expression to its right at the start of a string. It matches every such instance before each `\n` in the string. |

`$` | Matches the expression to its left at the end of a string. It matches every such instance before each `\n` in the string. |

`.` | Matches any character except line terminators like `\n` . |

`\` | Escapes special characters or denotes character classes. |

`A|B` | Matches expression `A` or `B` . If `A` is matched first, `B` is left untried. |

`+` | Greedily matches the expression to its left 1 or more times. |

`*` | Greedily matches the expression to its left 0 or more times. |

`?` | Greedily matches the expression to its left 0 or 1 times. But if `?` is added to qualifiers (`+` , `*` , and `?` itself) it will perform matches in a non-greedy manner. |

`{m}` | Matches the expression to its left `m` times, and not less. |

`{m,n}` | Matches the expression to its left `m` to `n` times, and not less. |

`{m,n}?` | Matches the expression to its left `m` times, and ignores `n` . See `?` above. |

Character Classes (Special Sequences) | |

`\w` | Matches alphanumeric characters, which means `a-z` , `A-Z` , and `0-9` . It also matches the underscore, `_` . |

`\d` | Matches digits, which means `0-9` . |

`\D` | Matches any non-digits. |

`\s` | Matches whitespace characters, which include the `\t` , `\n` , `\r` , and space characters. |

`\S` | Matches non-whitespace characters. |

`\b` | Matches the boundary (or empty string) at the start and end of a word, that is, between `\w` and `\W` . |

`\B` | Matches where `\b` does not, that is, the boundary of `\w` characters. |

`\A` | Matches the expression to its right at the absolute start of a string whether in single or multi-line mode. |

`\Z` | Matches the expression to its left at the absolute end of a string whether in single or multi-line mode. |

Sets | |

`[ ]` | Contains a set of characters to match. |

`[abc]` | Matches either `a` , `b` , or `c` . It does not match `abc` . |

`[a-z]` | Matches any alphabet from `a` to `z` . |

`[a\-z]` | Matches `a` , `-` , or `z` . It matches `-` because `\` escapes it. |

`[a-]` | Matches `a` or `-` , because `-` is not being used to indicate a series of characters. |

`[-a]` | As above, matches `a` or `-` . |

`[a-z0-9]` | Matches characters from `a` to `z` and also from `0` to `9` . |

`[(+*)]` | Special characters become literal inside a set, so this matches `(` , `+` , `*` , and `)` . |

`[^ab5]` | Adding `^` excludes any character in the set. Here, it matches characters that are not `a` , `b` , or `5` . |

Groups | |

`( )` | Matches the expression inside the parentheses and groups it. |

`(? )` | Inside parentheses like this, `?` acts as an extension notation. Its meaning depends on the character immediately to its right. |

`(?PAB)` | Matches the expression `AB` , and it can be accessed with the group name. |

`(?aiLmsux)` | Here, `a` , `i` , `L` , `m` , `s` , `u` , and `x` are flags: |

`a` — Matches ASCII only`i` — Ignore case`L` — Locale dependent`m` — Multi-line`s` — Matches all`u` — Matches unicode`x` — Verbose
| |

`(?:A)` | Matches the expression as represented by `A` , but unlike `(?PAB)` , it cannot be retrieved afterwards. |

`(?#...)` | A comment. Contents are for us to read, not for matching. |

`A(?=B)` | Lookahead assertion. This matches the expression `A` only if it is followed by `B` . |

`A(?!B)` | Negative lookahead assertion. This matches the expression `A` only if it is not followed by `B` . |

`(?<=B)A` | Positive lookbehind assertion. This matches the expression `A` only if `B` is immediately to its left. This can only matched fixed length expressions. |

`(?<!B)A` | Negative lookbehind assertion. This matches the expression `A` only if `B` is not immediately to its left. This can only matched fixed length expressions. |

`(?P=name)` | Matches the expression matched by an earlier group named “name”. |

`(...)\1` | The number `1` corresponds to the first group to be matched. If we want to match more instances of the same expresion, simply use its number instead of writing out the whole expression again. We can use from `1` up to `99` such groups and their corresponding numbers. |

Some random text to test with, lets have #FFFFFF or #453. Some random dates: 1/2/03 2016-02-23 2/3/04 2015-1-11 13:57:24 02/05/1999 25-12-2012 Some URLs - https://www.generateit.net ftp://generateit.net ip: 255.121.14.25 or 2001:0db8:85a3:0000:0000:8a2e:0370:7334 Some emails - hello@here.com and hello@here.com.au /* CSS comments test */

#### How to Use?

The online regex tester is a handy tool to help you learn and check regex codes before using them in your projects.

- If you are new to regex, it might come in useful to check out the some of the examples on this webpage, just to get a feel of how they work.
- To test a regex expression, just enter the regular expression into the field above.
- Select which flags you would like to include with the regex expression.
- You can then enter the test data into the textarea.
- Finally click on 'Match' to view if your regular expression is working correctly.

#### Share this Tool

If you have enjoyed using this tool, please consider sharing this page with other users, just click on your preferred social media link or copy the webpage from the link below.