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*if\(\$\_\w+\['\w+'\]\s*==\s*['"]kung'\).{0,30}<form.{0,100}?uploader.{0,50}<input.{0,400}if\(\@copy\(\$_files.{0,100}upload sukses \!+.{0,50}upload gagal \!+.{0,50}?\} \} \}\s*\?>\s*(?=<\?php)
/
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)
if
matches the characters if literally (case insensitive)
\( matches the character ( with index 4010 (2816 or 508) literally (case insensitive)
\$ matches the character $ with index 3610 (2416 or 448) literally (case insensitive)
\_ matches the character _ with index 9510 (5F16 or 1378) literally (case insensitive)
\w
matches any word character (equivalent to [a-zA-Z0-9_])
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
\[ matches the character [ with index 9110 (5B16 or 1338) literally (case insensitive)
' matches the character ' with index 3910 (2716 or 478) literally (case insensitive)
\w
matches any word character (equivalent to [a-zA-Z0-9_])
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
' matches the character ' with index 3910 (2716 or 478) literally (case insensitive)
\] matches the character ] with index 9310 (5D16 or 1358) 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 characters == 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)
Match a single character present in the list below
['"]
'"
matches a single character in the list '" (case insensitive)
kung'
matches the characters kung' literally (case insensitive)
\) matches the character ) with index 4110 (2916 or 518) literally (case insensitive)
.
matches any character
<form
matches the characters <form literally (case insensitive)
.
matches any character
uploader
matches the characters uploader literally (case insensitive)
.
matches any character
<input
matches the characters <input literally (case insensitive)
.
matches any character
if
matches the characters if literally (case insensitive)
\( matches the character ( with index 4010 (2816 or 508) literally (case insensitive)
\@ matches the character @ with index 6410 (4016 or 1008) literally (case insensitive)
copy
matches the characters copy literally (case insensitive)
\( matches the character ( with index 4010 (2816 or 508) literally (case insensitive)
\$ matches the character $ with index 3610 (2416 or 448) literally (case insensitive)
_files
matches the characters _files literally (case insensitive)
.
matches any character
upload sukses
matches the characters upload sukses literally (case insensitive)
\!
matches the character ! with index 3310 (2116 or 418) literally (case insensitive)
.
matches any character
upload gagal
matches the characters upload gagal literally (case insensitive)
\!
matches the character ! with index 3310 (2116 or 418) literally (case insensitive)
.
matches any character
\} matches the character } with index 12510 (7D16 or 1758) literally (case insensitive)
matches the character with index 3210 (2016 or 408) literally (case insensitive)
\} matches the character } with index 12510 (7D16 or 1758) literally (case insensitive)
matches the character with index 3210 (2016 or 408) literally (case insensitive)
\} matches the character } with index 12510 (7D16 or 1758) literally (case insensitive)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v ])
\? matches the character ? with index 6310 (3F16 or 778) literally (case insensitive)
> matches the character > with index 6210 (3E16 or 768) literally (case insensitive)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v ])
Positive Lookahead
(?=<\?php)
Assert that the Regex below matches
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