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
/
\b(?:(?:https|ftp):\/\/)(?:\S(?::\S)?@)?(?:(?!10(?:\.\d){3})(?!127(?:\.\d){3})(?!169\.254(?:\.\d){2})(?!192\.168(?:\.\d){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d){2})(?:[1-9]\d|1\d\d|2[01]\d|22[0-3])(?:\.(?:1\d|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]-)*[a-z\x{00a1}-\x{ffff}0-9])(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]-)*[a-z\x{00a1}-\x{ffff}0-9])*(?:\.(?:[a-z\x{00a1}-\x{ffff}])))(?::\d)?(?:\/[^\s])?\b
/
gi
\b assert position at a word boundary: (^\w|\w$|\W\w|\w\W)
Non-capturing group
(?:(?:https|ftp):\/\/)
Non-capturing group
(?:https|ftp)
1st Alternative
https
http matches the characters http literally (case insensitive)
s
matches the character s literally (case insensitive)
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
2nd Alternative
ftp
ftp matches the characters ftp literally (case insensitive)
: matches the character : literally (case insensitive)
\/ matches the character / literally (case insensitive)
\/ matches the character / literally (case insensitive)
Non-capturing group
(?:\S(?::\S)?@)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
\S
matches any non-whitespace character (equivalent to [^\r\n\t\f\v ])
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
Non-capturing group
(?::\S)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
: matches the character : literally (case insensitive)
\S
matches any non-whitespace character (equivalent to [^\r\n\t\f\v ])
@ matches the character @ literally (case insensitive)
Non-capturing group
(?:(?!10(?:\.\d){3})(?!127(?:\.\d){3})(?!169\.254(?:\.\d){2})(?!192\.168(?:\.\d){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d){2})(?:[1-9]\d|1\d\d|2[01]\d|22[0-3])(?:\.(?:1\d|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]-)*[a-z\x{00a1}-\x{ffff}0-9])(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]-)*[a-z\x{00a1}-\x{ffff}0-9])*(?:\.(?:[a-z\x{00a1}-\x{ffff}])))
1st Alternative
(?!10(?:\.\d){3})(?!127(?:\.\d){3})(?!169\.254(?:\.\d){2})(?!192\.168(?:\.\d){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d){2})(?:[1-9]\d|1\d\d|2[01]\d|22[0-3])(?:\.(?:1\d|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d|1\d\d|2[0-4]\d|25[0-4]))
Negative Lookahead
(?!10(?:\.\d){3})
Assert that the Regex below does not match
10 matches the characters 10 literally (case insensitive)
Non-capturing group
(?:\.\d){3}
{3} matches the previous token exactly 3 times
\. matches the character . literally (case insensitive)
\d
matches a digit (equivalent to [0-9])
Negative Lookahead
(?!127(?:\.\d){3})
Assert that the Regex below does not match
127 matches the characters 127 literally (case insensitive)
Non-capturing group
(?:\.\d){3}
Negative Lookahead
(?!169\.254(?:\.\d){2})
Assert that the Regex below does not match
169 matches the characters 169 literally (case insensitive)
\. matches the character . literally (case insensitive)
254 matches the characters 254 literally (case insensitive)
Non-capturing group
(?:\.\d){2}
Negative Lookahead
(?!192\.168(?:\.\d){2})
Assert that the Regex below does not match
192 matches the characters 192 literally (case insensitive)
\. matches the character . literally (case insensitive)
168 matches the characters 168 literally (case insensitive)
Non-capturing group
(?:\.\d){2}
Negative Lookahead
(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d){2})
Assert that the Regex below does not match
Non-capturing group
(?:[1-9]\d|1\d\d|2[01]\d|22[0-3])
Non-capturing group
(?:\.(?:1\d|2[0-4]\d|25[0-5])){2}
Non-capturing group
(?:\.(?:[1-9]\d|1\d\d|2[0-4]\d|25[0-4]))
2nd Alternative
(?:(?:[a-z\x{00a1}-\x{ffff}0-9]-)*[a-z\x{00a1}-\x{ffff}0-9])(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]-)*[a-z\x{00a1}-\x{ffff}0-9])*(?:\.(?:[a-z\x{00a1}-\x{ffff}]))
Non-capturing group
(?:(?:[a-z\x{00a1}-\x{ffff}0-9]-)*[a-z\x{00a1}-\x{ffff}0-9])
Non-capturing group
(?:[a-z\x{00a1}-\x{ffff}0-9]-)*
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
Match a single character present in the list below
[a-z\x{00a1}-\x{ffff}0-9]
-
matches the character - literally (case insensitive)
Match a single character present in the list below
[a-z\x{00a1}-\x{ffff}0-9]
Non-capturing group
(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]-)*[a-z\x{00a1}-\x{ffff}0-9])*
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
\. matches the character . literally (case insensitive)
Non-capturing group
(?:[a-z\x{00a1}-\x{ffff}0-9]-)*
Match a single character present in the list below
[a-z\x{00a1}-\x{ffff}0-9]
Non-capturing group
(?:\.(?:[a-z\x{00a1}-\x{ffff}]))
\. matches the character . literally (case insensitive)
Non-capturing group
(?:[a-z\x{00a1}-\x{ffff}])
Non-capturing group
(?::\d)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
: matches the character : literally (case insensitive)
\d
matches a digit (equivalent to [0-9])
{2,5} matches the previous token between 2 and 5 times, as many times as possible, giving back as needed (greedy)
Non-capturing group
(?:\/[^\s])?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
\/ matches the character / literally (case insensitive)
Match a single character not present in the list below
[^\s]
\b assert position at a word boundary: (^\w|\w$|\W\w|\w\W)
Global pattern flags
g modifier: global. All matches (don't return after first match)
i modifier: insensitive. Case insensitive match (ignores case of [a-zA-Z])
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/
gi

Test String