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
/
&foo=([\S\s]*?)(?=&foo=|$)
/
g
&foo= matches the characters &foo= literally (case sensitive)
1st Capturing Group
([\S\s]*?)
Match a single character present in the list below
[\S\s]*?
*? Quantifier — Matches between zero and unlimited times, as few times as possible, expanding as needed (lazy)
\S matches any non-whitespace character (equal to [^\r\n\t\f\v \u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff])
\s matches any whitespace character (equal to [\r\n\t\f\v \u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff])
Positive Lookahead
(?=&foo=|$)
Assert that the Regex below matches
1st Alternative
&foo=
&foo= matches the characters &foo= literally (case sensitive)
2nd Alternative
$
$ asserts position at the end of the string
Global pattern flags
g modifier: global. All matches (don't return after first match)
Your regular expression does not match the subject string.

Regular Expression
No Match

/
/
g

Test String