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
/
^(?:[[:^print:][:cntrl:]\s]|GIF89.{0,20})*<\?(?:php)?\s*\$yourmail\s*=.{0,40}?put your e-mail here.{0,190}?scam[\s\w]+by\s*walid\s*nabil.{0,70}?facebook\.com\/oreo0o.{0,50}?walid_nabil(?:[^>]+>\s*)?$
/
gis
^ asserts position at start of the string
Non-capturing group
(?:[[:^print:][:cntrl:]\s]|GIF89.{0,20})*
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
1st Alternative
[[:^print:][:cntrl:]\s]
Match a single character present in the list below
[[:^print:][:cntrl:]\s]
[:^print:] matches the negation of print
[:cntrl:] matches a control character [\x00-\x1F\x7F]
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
2nd Alternative
GIF89.{0,20}
GIF89
matches the characters GIF89 literally (case insensitive)
.
matches any character
{0,20} matches the previous token between 0 and 20 times, as many times as possible, giving back as needed (greedy)
< matches the character < with index 6010 (3C16 or 748) literally (case insensitive)
\? matches the character ? with index 6310 (3F16 or 778) literally (case insensitive)
Non-capturing group
(?:php)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
php
matches the characters php literally (case insensitive)
\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)
\$ matches the character $ with index 3610 (2416 or 448) literally (case insensitive)
yourmail
matches the characters yourmail literally (case insensitive)
\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)
= matches the character = with index 6110 (3D16 or 758) literally (case insensitive)
.
matches any character
{0,40}? matches the previous token between 0 and 40 times, as few times as possible, expanding as needed (lazy)
put your e-mail here
matches the characters put your e-mail here literally (case insensitive)
.
matches any character
{0,190}? matches the previous token between 0 and 190 times, as few times as possible, expanding as needed (lazy)
scam
matches the characters scam literally (case insensitive)
Match a single character present in the list below
[\s\w]
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
\w matches any word character (equivalent to [a-zA-Z0-9_])
by
matches the characters by literally (case insensitive)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v ])
walid
matches the characters walid literally (case insensitive)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v ])
nabil
matches the characters nabil literally (case insensitive)
.
matches any character
facebook
matches the characters facebook literally (case insensitive)
\. matches the character . with index 4610 (2E16 or 568) literally (case insensitive)
com
matches the characters com literally (case insensitive)
\/ matches the character / with index 4710 (2F16 or 578) literally (case insensitive)
oreo0o
matches the characters oreo0o literally (case insensitive)
.
matches any character
walid_nabil
matches the characters walid_nabil literally (case insensitive)
Non-capturing group
(?:[^>]+>\s*)?
$ asserts position at the end of the string, or before the line terminator right at the end of the string (if any)
Global pattern flags
g modifier: global. All matches (don't return after first match)
i modifier: insensitive. Case insensitive match (ignores case of [a-zA-Z])
s modifier: single line. Dot matches newline characters
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/
gis

Test String