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 (RE2)

Function

  • Match
  • Substitution
  • List
  • Unit Tests
/
(?:https?:\/\/)?(?:www.|web.|m.)?(?:facebook|fb).com\/(?:video.php\?v=\/?|\?v=\/?|watch\/\?v=\/?|watch\/\?v=\/?)|\S+\/videos\/?
/
gm
1st Alternative
(?:https?:\/\/)?(?:www.|web.|m.)?(?:facebook|fb).com\/(?:video.php\?v=\/?|\?v=\/?|watch\/\?v=\/?|watch\/\?v=\/?)
Non-capturing group
(?:https?:\/\/)?
? Quantifier — Matches between zero and one times, as many times as possible, giving back as needed (greedy)
http matches the characters http literally (case sensitive)
s?
matches the character s literally (case sensitive)
? Quantifier — Matches between zero and one times, as many times as possible, giving back as needed (greedy)
: matches the character : literally (case sensitive)
\/ matches the character / literally (case sensitive)
\/ matches the character / literally (case sensitive)
Non-capturing group
(?:www.|web.|m.)?
? Quantifier — Matches between zero and one times, as many times as possible, giving back as needed (greedy)
1st Alternative
www.
www matches the characters www literally (case sensitive)
. matches any character (except for line terminators)
2nd Alternative
web.
web matches the characters web literally (case sensitive)
. matches any character (except for line terminators)
3rd Alternative
m.
m matches the character m literally (case sensitive)
. matches any character (except for line terminators)
Non-capturing group
(?:facebook|fb)
1st Alternative
facebook
facebook matches the characters facebook literally (case sensitive)
2nd Alternative
fb
fb matches the characters fb literally (case sensitive)
. matches any character (except for line terminators)
com matches the characters com literally (case sensitive)
\/ matches the character / literally (case sensitive)
Non-capturing group
(?:video.php\?v=\/?|\?v=\/?|watch\/\?v=\/?|watch\/\?v=\/?)
1st Alternative
video.php\?v=\/?
video matches the characters video literally (case sensitive)
. matches any character (except for line terminators)
php matches the characters php literally (case sensitive)
\? matches the character ? literally (case sensitive)
v= matches the characters v= literally (case sensitive)
\/?
matches the character / literally (case sensitive)
2nd Alternative
\?v=\/?
\? matches the character ? literally (case sensitive)
v= matches the characters v= literally (case sensitive)
\/?
matches the character / literally (case sensitive)
3rd Alternative
watch\/\?v=\/?
4th Alternative
watch\/\?v=\/?
2nd Alternative
\S+\/videos\/?
\S+
matches any non-whitespace character (equal to [^\r\n\t\f\v ])
+ Quantifier — Matches between one and unlimited times, as many times as possible, giving back as needed (greedy)
\/ matches the character / literally (case sensitive)
videos matches the characters videos literally (case sensitive)
\/?
matches the character / literally (case sensitive)
? Quantifier — Matches between zero and one times, as many times as possible, giving back as needed (greedy)
Global pattern flags
g modifier: global. All matches (don't return after first match)
m modifier: multi line. Causes ^ and $ to match the begin/end of each line (not only begin/end of string)
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/
gm

Test String