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* (?= (?: SELECT | FROM ) ) | (?<! ^ ) \G ) [^*?"] \K ( SELECT | FROM ) # (1)
/
gx
Non-capturing group
(?: " \s* (?= (?: SELECT | FROM ) ) | (?<! ^ ) \G )
1st Alternative
" \s* (?= (?: SELECT | FROM ) )
" matches the character " 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)
Positive Lookahead
(?= (?: SELECT | FROM ) )
Assert that the Regex below matches
Non-capturing group
(?: SELECT | FROM )
1st Alternative
SELECT
2nd Alternative
FROM
2nd Alternative
(?<! ^ ) \G
Negative Lookbehind
(?<! ^ )
Assert that the Regex below does not match
^ asserts position at start of the string
\G asserts position at the end of the previous match or the start of the string for the first match
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 the character " literally (case sensitive)
\K resets the starting point of the reported match. Any previously consumed characters are no longer included in the final match
1st Capturing Group
( SELECT | FROM )
1st Alternative
SELECT
SELECT matches the characters SELECT literally (case sensitive)
2nd Alternative
FROM
FROM matches the characters FROM literally (case sensitive)
Comment: (1)
Global pattern flags
g modifier: global. All matches (don't return after first match)
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

/
/
gx

Test String