Regular Expressions 101

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

Save & Share

Flavor

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

Function

  • Match
  • Substitution
  • List
  • Unit Tests (14)
/
<link(?=[^<>]opensearch)(?:[^h]|h(?!ref))*+href=["']\K([^<>'"\s](?:\/(?!>)|\b))(?=[^<>]>)
/
igmx
<link matches the characters <link literally (case insensitive)
Positive Lookahead
(?=[^<>]opensearch)
Assert that the Regex below matches
Match a single character not present in the list below
[^<>]
*? matches the previous token between zero and unlimited times, as few times as possible, expanding as needed (lazy)
<> matches a single character in the list <> (case insensitive)
opensearch matches the characters opensearch literally (case insensitive)
Non-capturing group
(?:[^h]|h(?!ref))*+
*+ matches the previous token between zero and unlimited times, as many times as possible, without giving back (possessive)
1st Alternative
[^h]
Match a single character not present in the list below
[^h]
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
h matches the character h literally (case insensitive)
2nd Alternative
h(?!ref)
h matches the character h literally (case insensitive)
Negative Lookahead
(?!ref)
Assert that the Regex below does not match
ref matches the characters ref literally (case insensitive)
href= matches the characters href= literally (case insensitive)
Match a single character present in the list below
["']
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
"' matches a single character in the list "' (case insensitive)
\K resets the starting point of the reported match. Any previously consumed characters are no longer included in the final match
1st Capturing Group
([^<>'"\s](?:\/(?!>)|\b))
Match a single character not present in the list below
[^<>'"\s]
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
<>'" matches a single character in the list <>'" (case insensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
Non-capturing group
(?:\/(?!>)|\b)
Positive Lookahead
(?=[^<>]>)
Assert that the Regex below matches
Match a single character not present in the list below
[^<>]
> matches the character > literally (case insensitive)
Global pattern flags
i modifier: insensitive. Case insensitive match (ignores case of [a-zA-Z])
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)
x modifier: extended. Spaces and text after a # in the pattern are ignored
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/
igmx

Test String