Enter a pattern and the matches light up in the text.
- To paste into JavaScript
/(\d{2})-(\d{3})/g
Enter a pattern and the matches light up in the text.
In the text
Matches
How to use it in three steps
Step by step, with this page's example.
- 01
Enter the pattern and flags.
- 02
Paste the text to test.
- 03
See matches and groups live.
Pattern (\d{2})-(\d{3}) on the text "Codes: 00-950 Alpha, 30-001 Beta, 80-827 Gamma"
00-950 (group 1: 00, group 2: 950)
30-001 (group 1: 30, group 2: 001)
80-827 (group 1: 80, group 2: 827) Questions
- What is a regular expression?
- A regular expression (regex) is a pattern that describes pieces of text, for example (\d{2})-(\d{3}) matches the postal code 00-950. This tester highlights the matches, capture groups and flags as you type, using your browser's JavaScript engine, and sends nothing anywhere.
- How do I test a regex online?
- Enter the pattern and flags, paste the text to test and watch the matches and groups update live. Everything is calculated in your browser.
- How do I write a regex for a postal code?
- The pattern \d{2}-\d{3} matches a Polish postal code such as 00-950. Paste it into the pattern field; brackets around the digits, as in (\d{2})-(\d{3}), show each part in its own group.
- Which regex engine does it use?
- The browser's JavaScript engine. Its syntax is close to PCRE, but not everything from other languages behaves the same.
- What is the g flag for?
- It finds every match instead of stopping at the first.