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
/
(?:\#|\/\/)[^\n\r]*(?<![\?>])
/
Non-capturing group
(?:\#|\/\/)
1st Alternative
\#
\# matches the character # with index 3510 (2316 or 438) literally (case sensitive)
2nd Alternative
\/\/
\/ matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
\/ matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
Match a single character not present in the list below
[^\n\r]
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
\n matches a line-feed (newline) character (ASCII 10)
\r matches a carriage return (ASCII 13)
Negative Lookbehind
(?<![\?>])
Assert that the Regex below does not match
Match a single character present in the list below
[\?>]
\? matches the character ? with index 6310 (3F16 or 778) literally (case sensitive)
> matches the character > with index 6210 (3E16 or 768) literally (case sensitive)
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/

Test String