Regular Expressions 101

Save & Share

  • Save Regex
    ctrl+s
  • Update Regex
    ctrl+⇧+s

Flavor

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

Function

  • Match
  • Substitution
  • List
  • Unit Tests
/
^(\S+|\S+\s+\d+\s+\S+) \S+ named\[\d+\]: client(?: \S+)? (\S+)\#\d+(\s\(\S+\))?\:( view external\:)? (update|zone transfer|query \(cache\)) \'[^\']*\' denied$
/
gm
^ asserts position at start of a line
1st Capturing Group
(\S+|\S+\s+\d+\s+\S+)
1st Alternative
\S+
\S
matches any non-whitespace character (equivalent to [^\r\n\t\f\v ])
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
2nd Alternative
\S+\s+\d+\s+\S+
\S
matches any non-whitespace character (equivalent to [^\r\n\t\f\v ])
+ 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 ])
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
\d
matches a digit (equivalent to [0-9])
+ 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 ])
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
\S
matches any non-whitespace character (equivalent to [^\r\n\t\f\v ])
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
matches the character with index 3210 (2016 or 408) literally (case sensitive)
\S
matches any non-whitespace character (equivalent to [^\r\n\t\f\v ])
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
named
matches the characters named literally (case sensitive)
\[ matches the character [ with index 9110 (5B16 or 1338) literally (case sensitive)
\d
matches a digit (equivalent to [0-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 9310 (5D16 or 1358) literally (case sensitive)
: client
matches the characters : client literally (case sensitive)
Non-capturing group
(?: \S+)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
matches the character with index 3210 (2016 or 408) literally (case sensitive)
\S
matches any non-whitespace character (equivalent to [^\r\n\t\f\v ])
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
matches the character with index 3210 (2016 or 408) literally (case sensitive)
2nd Capturing Group
(\S+)
\S
matches any non-whitespace character (equivalent to [^\r\n\t\f\v ])
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
\# matches the character # with index 3510 (2316 or 438) literally (case sensitive)
\d
matches a digit (equivalent to [0-9])
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
3rd Capturing Group
(\s\(\S+\))?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
\( matches the character ( with index 4010 (2816 or 508) literally (case sensitive)
\S
matches any non-whitespace character (equivalent to [^\r\n\t\f\v ])
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
\) matches the character ) with index 4110 (2916 or 518) literally (case sensitive)
\: matches the character : with index 5810 (3A16 or 728) literally (case sensitive)
4th Capturing Group
( view external\:)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
view external
matches the characters view external literally (case sensitive)
\: matches the character : with index 5810 (3A16 or 728) literally (case sensitive)
matches the character with index 3210 (2016 or 408) literally (case sensitive)
5th Capturing Group
(update|zone transfer|query \(cache\))
1st Alternative
update
update
matches the characters update literally (case sensitive)
2nd Alternative
zone transfer
3rd Alternative
query \(cache\)
matches the character with index 3210 (2016 or 408) literally (case sensitive)
\' matches the character ' with index 3910 (2716 or 478) literally (case sensitive)
Match a single character not present in the list below
[^\']
\' matches the character ' with index 3910 (2716 or 478) literally (case sensitive)
denied
matches the characters denied literally (case sensitive)
$ asserts position at the end of a line
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)
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/
gm

Test String