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
"
time=(\d+\-\d+\-\d+\s+\d+:\d+:\d+)\|action=(\w+)\|[f_name=(\S*)]?\|has_accounting=0
"
time=
matches the characters time= literally (case sensitive)
1st Capturing Group
(\d+\-\d+\-\d+\s+\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 4510 (2D16 or 558) 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 4510 (2D16 or 558) 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)
\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 12410 (7C16 or 1748) literally (case sensitive)
action=
matches the characters action= literally (case sensitive)
2nd Capturing Group
(\w+)
\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 12410 (7C16 or 1748) literally (case sensitive)
Match a single character present in the list below
[f_name=(\S*)]
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
f_name=(
matches a single character in the list f_name=( (case sensitive)
\S matches any non-whitespace character (equivalent to [^\r\n\t\f\v ])
*)
matches a single character in the list *) (case sensitive)
\| matches the character | with index 12410 (7C16 or 1748) literally (case sensitive)
has_accounting=0
matches the characters has_accounting=0 literally (case sensitive)
Your regular expression does not match the subject string.

Regular Expression
No Match

r"
"

Test String