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
/
^IF[ ]*EXISTS[ ]*[(]SELECT[ ]*1[ ]*FROM[ ]*sysobjects[ ]*o,[ ]*sysusers[ ]*u[ ]*WHERE[ ]*TYPE[ ]*=[ ]*'P'[ ]*and[ ]*o[.]name[ ]*=[ ]*\'\w*\'[ ]*AND[ ]*o[.]uid[ ]*=[ ]*u[.]uid[ ]*and[ ]*u[.]name[ ]*=[ ]*\'\w*\'[)][\s]*[ ]*DROP[ ]*PROCEDURE[ ]*\S*[ ]*\s*[ ]*GO
/
gmi
^ asserts position at start of a line
IF
matches the characters IF literally (case insensitive)
Match a single character present in the list below
[ ]
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
matches the character with index 3210 (2016 or 408) literally (case insensitive)
EXISTS
matches the characters EXISTS literally (case insensitive)
Match a single character present in the list below
[ ]
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
matches the character with index 3210 (2016 or 408) literally (case insensitive)
Match a single character present in the list below
[(]
( matches the character ( with index 4010 (2816 or 508) literally (case insensitive)
SELECT
matches the characters SELECT literally (case insensitive)
Match a single character present in the list below
[ ]
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
matches the character with index 3210 (2016 or 408) literally (case insensitive)
1 matches the character 1 with index 4910 (3116 or 618) literally (case insensitive)
Match a single character present in the list below
[ ]
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
matches the character with index 3210 (2016 or 408) literally (case insensitive)
FROM
matches the characters FROM literally (case insensitive)
Match a single character present in the list below
[ ]
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
matches the character with index 3210 (2016 or 408) literally (case insensitive)
sysobjects
matches the characters sysobjects literally (case insensitive)
Match a single character present in the list below
[ ]
o,
matches the characters o, literally (case insensitive)
Match a single character present in the list below
[ ]
sysusers
matches the characters sysusers literally (case insensitive)
Match a single character present in the list below
[ ]
u matches the character u with index 11710 (7516 or 1658) literally (case insensitive)
Match a single character present in the list below
[ ]
WHERE
matches the characters WHERE literally (case insensitive)
Match a single character present in the list below
[ ]
TYPE
matches the characters TYPE literally (case insensitive)
Match a single character present in the list below
[ ]
= matches the character = with index 6110 (3D16 or 758) literally (case insensitive)
Match a single character present in the list below
[ ]
'P'
matches the characters 'P' literally (case insensitive)
Match a single character present in the list below
[ ]
and
matches the characters and literally (case insensitive)
Match a single character present in the list below
[ ]
o matches the character o with index 11110 (6F16 or 1578) literally (case insensitive)
Match a single character present in the list below
[.]
name
matches the characters name literally (case insensitive)
Match a single character present in the list below
[ ]
= matches the character = with index 6110 (3D16 or 758) literally (case insensitive)
Match a single character present in the list below
[ ]
\' 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 character ' with index 3910 (2716 or 478) literally (case insensitive)
Match a single character present in the list below
[ ]
AND
matches the characters AND literally (case insensitive)
Match a single character present in the list below
[ ]
o matches the character o with index 11110 (6F16 or 1578) literally (case insensitive)
Match a single character present in the list below
[.]
uid
matches the characters uid literally (case insensitive)
Match a single character present in the list below
[ ]
= matches the character = with index 6110 (3D16 or 758) literally (case insensitive)
Match a single character present in the list below
[ ]
u matches the character u with index 11710 (7516 or 1658) literally (case insensitive)
Match a single character present in the list below
[.]
uid
matches the characters uid literally (case insensitive)
Match a single character present in the list below
[ ]
and
matches the characters and literally (case insensitive)
Match a single character present in the list below
[ ]
u matches the character u with index 11710 (7516 or 1658) literally (case insensitive)
Match a single character present in the list below
[.]
name
matches the characters name literally (case insensitive)
Match a single character present in the list below
[ ]
= matches the character = with index 6110 (3D16 or 758) literally (case insensitive)
Match a single character present in the list below
[ ]
\' 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 character ' with index 3910 (2716 or 478) literally (case insensitive)
Match a single character present in the list below
[)]
Match a single character present in the list below
[\s]
Match a single character present in the list below
[ ]
DROP
matches the characters DROP literally (case insensitive)
Match a single character present in the list below
[ ]
PROCEDURE
matches the characters PROCEDURE literally (case insensitive)
Match a single character present in the list below
[ ]
\S
matches any non-whitespace character (equivalent to [^\r\n\t\f\v \u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff])
Match a single character present in the list below
[ ]
\s
matches any whitespace character (equivalent to [\r\n\t\f\v \u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff])
Match a single character present in the list below
[ ]
GO
matches the characters GO literally (case insensitive)
Global pattern flags
g modifier: global. All matches (don't return after first match)
m modifier: multi line. Causes ^ and $ to match the begin/end of each line (not only begin/end of string)
i modifier: insensitive. Case insensitive match (ignores case of [a-zA-Z])
Your regular expression does not match the subject string.

Regular Expression
No Match

/
/
gmi

Test String