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
/
((?:[\t ]*(?:R|RE|F|FW|FWD):[\t ]*)*)(.*)
/
gmi
1st Capturing Group
((?:[\t ]*(?:R|RE|F|FW|FWD):[\t ]*)*)
Non-capturing group
(?:[\t ]*(?:R|RE|F|FW|FWD):[\t ]*)*
* 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
[\t ]
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
\t matches a tab character (ASCII 9)
matches the character with index 3210 (2016 or 408) literally (case insensitive)
Non-capturing group
(?:R|RE|F|FW|FWD)
1st Alternative
R
R matches the character R with index 8210 (5216 or 1228) literally (case insensitive)
2nd Alternative
RE
RE
matches the characters RE literally (case insensitive)
3rd Alternative
F
F matches the character F with index 7010 (4616 or 1068) literally (case insensitive)
4th Alternative
FW
FW
matches the characters FW literally (case insensitive)
5th Alternative
FWD
FWD
matches the characters FWD literally (case insensitive)
: matches the character : with index 5810 (3A16 or 728) literally (case insensitive)
Match a single character present in the list below
[\t ]
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
\t matches a tab character (ASCII 9)
matches the character with index 3210 (2016 or 408) literally (case insensitive)
2nd Capturing Group
(.*)
.
matches any character (except for line terminators)
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
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