EditSafely

Test a String with Regex

Check whether a string matches a regular expression.

Runs on your device, nothing uploaded

Regular expression
One Match or No match per line, as a form validator would.
Try:

0 chars · 0 lines

Output

Check whether a string matches a regular expression.

Type or paste above to see the result here.

Example: Is it all digits?

What you paste never leaves this tab

Test a String with Regex is JavaScript that your browser has already downloaded, and it does the whole job on your own machine. On a normal site, the text you paste is sent to a server that can log it, cache it or keep it. Here it is read and transformed inside this tab and nowhere else.

  • No upload
  • No length limit
  • Works offline once loaded
  • Nothing stored or logged

How to use Test a String with Regex

  1. 1. Type the regular expression. Type the pattern in the Regular expression bar above the text, without the surrounding slashes, or tap a token chip such as \d or \w+. A mistake is named with its position, such as a missing ) at position 1.
  2. 2. Paste the text to test. Enter a single value like an email address or a longer block of text. Every match is tinted in the text as you type.
  3. 3. Set Ignore case, whole-string or per-line testing. Ignore case matches regardless of letter casing, Require the whole string to match anchors the pattern at both ends, and Test each line separately gives one Match or No match per line.
  4. 4. Read the verdict and the matches. The card says how many matches were found, and the table lists each match with its position and captured groups. Copy gives the full report.

When to use Test a String with Regex

Test a String with Regex checks whether a given piece of text matches a regular expression, with options to ignore case or require a full match. Use it to verify a pattern works correctly before wiring it into validation code.

  • Validating an email or phone pattern. You wrote a regex meant to validate email addresses or phone numbers and want to try it against several real and fake examples before adding it to a form's validation logic.
  • Debugging a failing validation rule. A form field keeps rejecting input that looks correct, and testing the exact regex against the exact string reveals whether the pattern or the input is the problem.
  • Checking whole-string versus partial matches. You are unsure whether your pattern is accidentally matching a substring instead of requiring the entire input to conform, and toggling whole-string matching clarifies the behavior.
  • Confirming a naming convention. A team style guide requires branch names or file names to follow a specific pattern, and you want to quickly check whether a proposed name satisfies the rule.

Examples

Is it all digits?

Input

12345

Output

Match: yes (1 match)
1. 12345 (position 1)

Validate emails, one per line

Input

ana@example.com
not an email
bo@site.org

Output

✓ ana@example.com
✗ not an email
✓ bo@site.org

Find every number

Input

Order 123 shipped on 2024-05-01

Output

Match: yes (4 matches)
1. 123 (position 7)
2. 2024 (position 22)
3. 05 (position 27)
4. 01 (position 30)

About the Test a String with Regex tool

Test a String with Regex does its work locally, right in the browser. Check whether a string matches a regular expression. There is no upload step, no queue and no account, and your data never travels over the network.

It belongs to the String Tools collection on EditSafely, a set of 159 small, focused String utilities that share the same instant, private workspace.

You can shape the output with 5 settings, including Regular expression, Ignore case, Require the whole string to match and Test each line separately, and the result refreshes the moment you change one. 3 worked examples further down the page show exactly what the tool produces for real inputs.

Running locally also makes the tool fast and dependable: results appear as soon as your input does, there is no server outage that can take it down mid-task, and confidential data can be processed without a second thought.

Frequently asked questions

Does Test a String with Regex cost anything?

Yes, it is completely free. All 2,943 tools on EditSafely work without an account, a subscription or usage limits.

Is it safe to paste sensitive or confidential data?

No data leaves your device. The whole tool is JavaScript that runs inside your browser tab, so there is no upload, no server-side processing and no log of what you did. If you disconnect from the internet after the page loads, it keeps working.

How much text can I process at once?

There is no fixed limit; your device's memory is the ceiling. Up to 10 MB the result updates as you type, after a short pause that grows with the size. Above 10 MB a Run button appears so typing stays smooth, and files open up to 50 MB. A very long result shows its first 2,000 lines on screen, while Copy and Download always include all of it.

Do I need to sign up or install anything?

Nothing to install and no account needed. Open the page in any up-to-date browser, including on a phone or tablet, and the tool is ready.

How do I use the result?

The output panel has a one-click copy button, and you can keep refining the input while you work; the result updates in place as you type.