Regular Expressions 101

@regex101
Donate
Sponsor
Contact
Bug Reports & Feedback
Wiki
Whats new?

Save & Share

  • Save Regex
    ctrl+s
  • Update Regex
    ctrl+⇧+s

Flavor

  • PCRE2 (PHP >=7.3)
  • PCRE (PHP <7.3)
  • ECMAScript (JavaScript)
  • Python 2.7
  • Golang
  • Java 8

Function

  • Match
  • Substitution
  • List
  • Unit Tests
/
^(([0-9]|[1-9][0-9]|1[0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]|2[0-4][0-9]|25[0-5])$
/
g
^ asserts position at start of the string
1st Capturing Group
(([0-9]|[1-9][0-9]|1[0-9]|2[0-4][0-9]|25[0-5])\.){3}
{3} matches the previous token exactly 3 times
A repeated capturing group will only capture the last iteration. Put a capturing group around the repeated group to capture all iterations or use a non-capturing group instead if you're not interested in the data
2nd Capturing Group
([0-9]|[1-9][0-9]|1[0-9]|2[0-4][0-9]|25[0-5])
1st Alternative
[0-9]
Match a single character present in the list below
[0-9]
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case sensitive)
2nd Alternative
[1-9][0-9]
Match a single character present in the list below
[1-9]
1-9 matches a single character in the range between 1 (index 49) and 9 (index 57) (case sensitive)
Match a single character present in the list below
[0-9]
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case sensitive)
3rd Alternative
1[0-9]
1 matches the character 1 literally (case sensitive)
Match a single character present in the list below
[0-9]
4th Alternative
2[0-4][0-9]
2 matches the character 2 literally (case sensitive)
Match a single character present in the list below
[0-4]
Match a single character present in the list below
[0-9]
5th Alternative
25[0-5]
\. matches the character . literally (case sensitive)
3rd Capturing Group
([0-9]|[1-9][0-9]|1[0-9]|2[0-4][0-9]|25[0-5])
1st Alternative
[0-9]
Match a single character present in the list below
[0-9]
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case sensitive)
2nd Alternative
[1-9][0-9]
Match a single character present in the list below
[1-9]
1-9 matches a single character in the range between 1 (index 49) and 9 (index 57) (case sensitive)
Match a single character present in the list below
[0-9]
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case sensitive)
3rd Alternative
1[0-9]
1 matches the character 1 literally (case sensitive)
Match a single character present in the list below
[0-9]
{2} matches the previous token exactly 2 times
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case sensitive)
4th Alternative
2[0-4][0-9]
2 matches the character 2 literally (case sensitive)
Match a single character present in the list below
[0-4]
0-4 matches a single character in the range between 0 (index 48) and 4 (index 52) (case sensitive)
Match a single character present in the list below
[0-9]
5th Alternative
25[0-5]
25 matches the characters 25 literally (case sensitive)
Match a single character present in the list below
[0-5]
$ asserts position at the end of the string, or before the line terminator right at the end of the string (if any)
Global pattern flags
g modifier: global. All matches (don't return after first match)
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/
g

Test String