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
"
(\d+:\d+:\d+\.\d+)\s+(\S+):\s+(\d+:\d+:\d+\.\d+)\s+op:\s+(\S+)\s+lun:\s+(\/\S+\/\S+)\s+lba:\s+(\d+)\s+0x[0-9A-F]+\s+xfer:\s+(\d+)\s+errno:\s+EIO:\s+'I/O error'$
"
1st Capturing Group
(\d+:\d+:\d+\.\d+)
\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 5810 (3A16 or 728) 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 5810 (3A16 or 728) 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 4610 (2E16 or 568) 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)
\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)
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 5810 (3A16 or 728) literally (case sensitive)
\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)
3rd Capturing Group
(\d+:\d+:\d+\.\d+)
\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 5810 (3A16 or 728) 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 5810 (3A16 or 728) 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 4610 (2E16 or 568) 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)
\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)
op:
matches the characters op: literally (case sensitive)
\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)
4th 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)
\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)
lun:
matches the characters lun: literally (case sensitive)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
5th Capturing Group
(\/\S+\/\S+)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
lba:
matches the characters lba: literally (case sensitive)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
6th Capturing Group
(\d+)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
0x
matches the characters 0x literally (case sensitive)
Match a single character present in the list below
[0-9A-F]
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
xfer:
matches the characters xfer: literally (case sensitive)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
7th Capturing Group
(\d+)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
errno:
matches the characters errno: literally (case sensitive)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
EIO:
matches the characters EIO: literally (case sensitive)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
'I/O error'
matches the characters 'I/O error' literally (case sensitive)
$ asserts position at the end of the string, or before the line terminator right at the end of the string (if any)
Your regular expression does not match the subject string.

Regular Expression
No Match

r"
"

Test String