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
"
^\s*<p>\s*(?:</?\w+/?>\s*)*<a href=\"(?:(?:[+a-z]:)?//(?:[^*\" >/.]\.)*(?:youtube\.com|youtu\.be)[/\"])\W*(?![*?\W\w]</(?:code|blockquote)>)(?#Separate start with youtube watch; lower TP rate, but most TP are not otherwise detected)
"
gm
^ asserts position at start of a line
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
<p> matches the characters <p> literally (case sensitive)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
Non-capturing group
(?:</?\w+/?>\s*)*
* matches the previous token between zero and unlimited 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 previous token between zero and one times, as many times as possible, giving back as needed (greedy)
\w
matches any word character (equivalent to [a-zA-Z0-9_])
/
matches the character / literally (case sensitive)
> matches the character > literally (case sensitive)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
<a href= matches the characters <a href= literally (case sensitive)
\" matches the character " literally (case sensitive)
Non-capturing group
(?:(?:[+a-z]:)?//(?:[^*\" >/.]\.)*(?:youtube\.com|youtu\.be)[/\"])
Non-capturing group
(?:[+a-z]:)?
// matches the characters // literally (case sensitive)
Non-capturing group
(?:[^*\" >/.]\.)*
Non-capturing group
(?:youtube\.com|youtu\.be)
Match a single character present in the list below
[/\"]
\W
matches any non-word character (equivalent to [^a-zA-Z0-9_])
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
Negative Lookahead
(?![*?\W\w]</(?:code|blockquote)>)
Assert that the Regex below does not match
Comment: Separate start with youtube watch; lower TP rate, but most TP are not otherwise detected
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.

Regular Expression
No Match

r"
"
gm

Test String

Code Generator

Generated Code

Loading code sample...
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report.
For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html