Regular Expressions 101

Save & Share

Flavor

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

Function

  • Match
  • Substitution
  • List
  • Unit Tests
"
<script>.*?(var.*?;).*?</script>
"
s
<script>
matches the characters <script> literally (case sensitive)
.
matches any character
*? matches the previous token between zero and unlimited times, as few times as possible, expanding as needed (lazy)
1st Capturing Group
(var.*?;)
var
matches the characters var literally (case sensitive)
.
matches any character
*? matches the previous token between zero and unlimited times, as few times as possible, expanding as needed (lazy)
; matches the character ; with index 5910 (3B16 or 738) literally (case sensitive)
.
matches any character
*? matches the previous token between zero and unlimited times, as few times as possible, expanding as needed (lazy)
</script>
matches the characters </script> literally (case sensitive)
Global pattern flags
s modifier: single line. Dot matches newline characters
Your regular expression does not match the subject string.

Regular Expression
No Match

r"
"
s

Test String