Skip to content

Regex Tester

Test a short regular expression against a short subject. The pattern h.llo matches hello once. If you omit the delimiters, the page wraps the pattern in tildes. The page does not run a pattern longer than 40 characters.

Result

Enter a pattern and a subject

How to Use

  1. 1 Enter a pattern of 1 to 40 characters.
  2. 2 Enter a subject of 1 to 200 characters.
  3. 3 h.llo against hello is 1 match.

Example Output

  • h.llo against hello is 1 match.

About This Tool

A nested repeating group is rejected. The subject can be at most 200 characters.

Using the Regex Tester

This page tests a pattern against a subject and counts the matches. The sample pattern is h.llo and the sample subject is hello. The headline is 1 match. A line labeled Matches shows 1, and a line labeled First match shows hello. The result sentence reads The pattern found 1 match in the subject. The page does not change the subject. It searches and counts.

The pattern must contain from 1 to 40 characters after it is trimmed. The subject must contain from 1 to 200 characters, and it must not be empty once spaces are set aside. A blank pattern is rejected with Enter a pattern from 1 to 40 characters. A pattern longer than 40 characters uses that same message. A blank subject, a subject of only spaces, and a subject longer than 200 characters are rejected with Enter a subject from 1 to 200 characters. The pattern is trimmed before the length check. The subject length counts the characters you typed, including spaces at the ends, as long as something remains after spaces are set aside.

If you omit the delimiters, the page wraps the pattern in tildes and adds the u flag. The sample h.llo is wrapped because it starts with a letter. A pattern that already starts with a character that is not a letter or a digit, and that ends with that same character, is used as you typed it. A nested repeat is rejected before the search, with Enter a pattern without a nested repeat. An invalid pattern, such as a lone opening parenthesis, is rejected with Enter a valid pattern.

The same pattern and the same subject return the same count on every run. The page does not replace text, does not save the subject, and does not fetch a page to search. The check for this form is small on purpose: h.llo against hello is 1 match, and the first match is hello.

What the Match Lines Show

The headline is the count, written as 1 match when the count is one and as a plural count otherwise. For h.llo against hello the headline is 1 match. The Matches line repeats the count as 1. The First match line shows the text of the first match, which for the sample is hello. If the pattern is valid and finds nothing, the first-match line says None and the count is 0. The result sentence uses the same headline wording: The pattern found 1 match in the subject. The subject itself is not rewritten.

The page is a count, not a substitution. h.llo means an h, then any one character, then llo, and hello fits that shape once. The dot in the sample is one character, and in hello that character is e. A longer subject can hold more than one match, and the headline then uses the plural wording while the first-match line still shows only the first one. The pattern still has to be from 1 to 40 characters, and the subject from 1 to 200.

How h.llo Finds hello

The pattern h.llo starts with a letter, so the delimiters are omitted and the page wraps it in tildes. A tilde that you included inside a wrapped pattern is escaped so it does not end the delimiter early. The search then runs against hello. One match is found, the first match is hello, and the headline is 1 match. Running h.llo against hello a second time returns that same count. The page does not ask for a replacement string, because it is not changing the subject.

Tags you check one per line are a different test. The Hreflang Validator checks hreflang tags you type, one per line. en is valid. english is not. The page does not fetch a site. Use it when the text is a list of language tags. Use this page when the text is a pattern and a subject, and the check you want is h.llo against hello as 1 match.

When the Page Adds Tildes

A pattern is kept as typed only when its first character is not a letter or a digit and the pattern ends with that same character. A pattern written as /h.llo/ already has those slashes, so the page uses it as the delimited pattern. Against hello it still finds 1 match, and the first match is still hello. A pattern written as h.llo has no such pair, so the page supplies tildes. You do not type the tildes yourself for the sample. If the pattern is only a letter, it is wrapped. If you need a delimiter character that is already the tilde, include a matching tilde at both ends yourself, or let the page escape tildes inside the wrapped form.

The wrap happens after the length check and after the nested-repeat check. A pattern of 41 characters is rejected before any tilde is added. A nested repeat is rejected before the search. A pattern that survives those checks and is still invalid as an expression, such as a lone opening parenthesis, is rejected with Enter a valid pattern. The subject is not the cause of that message. hello remains a valid subject beside a broken pattern.

One Match, a Wrapped Pattern, and a Rejected One

Enter h.llo as the pattern and hello as the subject. The headline is 1 match, the Matches line is 1, and the First match line is hello. Enter /h.llo/ against the same hello and confirm the count is still 1, because that pattern already has matching delimiters. Enter a lone opening parenthesis as the pattern and hello as the subject. The page rejects it with Enter a valid pattern. Enter a nested repeat such as (a+)+ and confirm the rejection Enter a pattern without a nested repeat. Enter a pattern of 41 characters and confirm Enter a pattern from 1 to 40 characters. Clear the subject and confirm Enter a subject from 1 to 200 characters.

Space removed from a JSON value is a different edit. The JSON Minifier removes insignificant space from a JSON value. {"a": 1} becomes {"a":1}. The page parses the text first, so a broken value is rejected instead of being trimmed by hand. Use it when you want a shorter JSON text. Use this page when you want a match count, and the sample count is 1 for h.llo against hello.

Forty Characters and Two Hundred

The pattern must be from 1 to 40 characters after trimming. The subject must be from 1 to 200 characters and must not be only spaces. h.llo and hello sit inside those spans, and the result is 1 match. A pattern of 40 characters is accepted if it is otherwise valid. A pattern of 41 characters is rejected with Enter a pattern from 1 to 40 characters. A subject of 200 characters is accepted if something remains after spaces are set aside. A subject of 201 characters is rejected. An empty subject and a subject of only spaces use Enter a subject from 1 to 200 characters.

The nested-repeat rejection is separate from the length rejection. A short pattern can still be rejected with Enter a pattern without a nested repeat. A pattern that is short, is not a nested repeat, and still cannot be compiled is rejected with Enter a valid pattern. The lone opening parenthesis is that case. The page does not return a partial count for a rejected pattern, and it does not clip a 41 character pattern down to 40. Spaces at the ends of the pattern are removed by the trim before the length is judged. Spaces at the ends of the subject count toward the 200 when the subject is not only spaces.

Mistakes With Delimiters and Repeats

The usual miss is to expect h.llo to fail because you did not type delimiters. The page wraps a pattern that omits them. The sample becomes a tilde-delimited pattern and finds 1 match in hello. Another miss is to put a quantifier on a group that already contains a quantifier and expect a count. That nested repeat is rejected with Enter a pattern without a nested repeat. A third miss is to treat a lone opening parenthesis as a pattern that matches nothing and still returns 0 matches. It is rejected with Enter a valid pattern, and no match line is the result. A fourth miss is to expect the subject to be rewritten as the match. The subject stays as typed. The lines report the count and the first match. A fifth miss is to paste more than 200 characters of subject and expect the first 200 to be searched. The extra characters cause a rejection.

A token split into a header and a payload is a different reading. The JWT Decoder decodes the header and the payload of a JSON Web Token. The page does not check the signature, so a decoded payload is not proof that the token is genuine. Use it when the text is a token with those parts. Use this page when the text is a pattern and a subject, and you want the match count for a pattern no longer than 40 characters.

Reading the Count and the First Match

Read the headline, then the Matches line, then the First match line. For the check, the headline is 1 match, the Matches line is 1, and the first match is hello. Those three should agree. If the headline says 1 match and the first match says None, the run you are looking at is not the sample. If you wrapped the pattern yourself as /h.llo/, the count against hello should still be 1. Write down the pattern exactly, including any delimiter characters you typed, because a later reader cannot tell from the count alone whether the page added tildes.

The page does not change the subject, so the note should keep hello beside the pattern h.llo. A count of 1 means one match was found, and the first-match line shows what that match was. Do not add a nested repeat and expect the page to simplify it. Shorten the pattern yourself until it is a single expression the page will compile, within 40 characters. Do not add a 201st character to the subject and expect a clipped search. The subject is searched whole or it is rejected.

Running h.llo Against hello Again

Enter h.llo and hello and confirm the headline is 1 match, the Matches line is 1, and the first match is hello. Enter /h.llo/ against hello and confirm the count is still 1. Enter a lone opening parenthesis and confirm Enter a valid pattern. Enter a nested repeat and confirm Enter a pattern without a nested repeat. Enter 41 pattern characters and confirm the 40 character message. Enter 201 subject characters and confirm the 200 character message. Clear the subject and confirm the subject message. Run h.llo against hello a second time and confirm 1 match matches the first run. The page does not rewrite hello on either run.

Indentation of a document is a different pass. The XML Formatter indents an XML document. <a><b>Hi</b></a> is formatted with each element on its own line. The page does not fetch a file and does not accept a document type. Use it when you want the elements broken onto lines. Use this page when you want a match count, with h.llo against hello as 1 match.

Where the Match Count Belongs

The count belongs next to the pattern and the subject that produced it. This page stops at the search. h.llo against hello is 1 match, and the first match is hello. The pattern is at most 40 characters. The subject is at most 200 characters. Omitted delimiters are supplied as tildes. A nested repeat is rejected. A lone opening parenthesis is rejected with Enter a valid pattern. The page does not replace the subject, does not fetch a page, and does not keep a library of patterns. If a different tool later changes the text, that change is not this count.

You can say the sample is stable: h.llo against hello returns 1 match on every run. You can say a pattern that already has matching end delimiters is used as typed. You can say the page wraps h.llo because the delimiters were omitted. You cannot say a nested repeat was searched anyway. You cannot say a 41 character pattern was clipped to 40. You cannot say the subject hello was rewritten into the match. The subject stays, and the lines report the count.

Checking the Sample Before a Longer Pattern

Start with h.llo and hello. The headline should be 1 match and the first match should be hello. Then try the same pattern with slashes already around it and confirm the count stays 1. Then try a lone opening parenthesis and confirm Enter a valid pattern. Then try a nested repeat and confirm the nested-repeat message, which is a different sentence from the valid-pattern message. Then try a blank subject and a subject of only spaces. Both should be rejected with Enter a subject from 1 to 200 characters. If the headline is 1 match and the first match is not hello, the subject is not the sample.

Cleaning a web address is a different edit. The URL Cleaner removes common tracking parameters from a URL and keeps the rest. A link with utm_source and id keeps id. The page does not open the link. Use it when you want those parameters dropped from an address. Use this page when you want to test a pattern, with h.llo against hello as the 1 match check, and with a pattern no longer than 40 characters.

Frequently Asked Questions

What does h.llo find in hello?

1 match. The Matches line is 1, and the First match line is hello. The subject is not changed.

What if the pattern has no delimiters?

The page wraps it in tildes. h.llo is wrapped because it starts with a letter. A pattern that already starts and ends with the same non-letter delimiter is used as typed.

How long can the pattern be?

From 1 to 40 characters after trimming. A blank pattern and a pattern of 41 characters are rejected with Enter a pattern from 1 to 40 characters.

How long can the subject be?

From 1 to 200 characters. A blank subject, a subject of only spaces, and a subject of 201 characters are rejected with Enter a subject from 1 to 200 characters.

What does a lone opening parenthesis do?

It is rejected with Enter a valid pattern. The page does not report 0 matches for that pattern.

What is a nested repeat?

A group that already contains a repeat and then has another repeat on the group. The page rejects it with Enter a pattern without a nested repeat.

Does the page change the subject?

No. It counts matches and shows the first match. hello stays hello when the pattern is h.llo.

Will h.llo against hello change on a second run?

No. The result is 1 match, and the first match is hello, every time those two fields are the inputs.

Does /h.llo/ also match hello?

Yes. That pattern already has matching slash delimiters, so the page uses it as typed and still finds 1 match.

Does the page fetch a page to search?

No. The subject is the text you type, up to 200 characters. The pattern is the expression you type, up to 40 characters.