Regular Expressions 101

@regex101
Donate
Sponsor
Contact
Bug Reports & Feedback
Wiki
Whats new?

Save & Share

Flavor

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

Function

  • Match
  • Substitution
  • List
  • Unit Tests
"
(?P<assign_op>(\:|\!|\?)?=)|(?P<token_subst>$|%(\<\@))|(?P<token_ident>[\w\d\.\,]+)|(?P<target_name_match>%\.?)|(?P<token_rule_sep>[:])|(?P<incr_op>\n)|(?P<line_end>\n)|(?P<comment_op>#[.*]+$)|(?P<adjust_parser>[\$%\s\t\:])
"
gm
1st Alternative
(?P<assign_op>(\:|\!|\?)?=)
Named Capture Group assign_op
(?P<assign_op>(\:|\!|\?)?=)
2nd Capturing Group
(\:|\!|\?)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
1st Alternative
\:
\: matches the character : literally (case sensitive)
2nd Alternative
\!
\! matches the character ! literally (case sensitive)
3rd Alternative
\?
\? matches the character ? literally (case sensitive)
= matches the character = literally (case sensitive)
2nd Alternative
(?P<token_subst>$|%(\<\@))
Named Capture Group token_subst
(?P<token_subst>$|%(\<\@))
1st Alternative
$
$ asserts position at the end of a line
2nd Alternative
%(\<\@)
% matches the character % literally (case sensitive)
4th Capturing Group
(\<\@)
\< matches the character < literally (case sensitive)
\@ matches the character @ literally (case sensitive)
3rd Alternative
(?P<token_ident>[\w\d\.\,]+)
Named Capture Group token_ident
(?P<token_ident>[\w\d\.\,]+)
Match a single character present in the list below
[\w\d\.\,]
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
\w matches any word character (equivalent to [a-zA-Z0-9_])
\d matches a digit (equivalent to [0-9])
\. matches the character . literally (case sensitive)
\, matches the character , literally (case sensitive)
4th Alternative
(?P<target_name_match>%\.?)
Named Capture Group target_name_match
(?P<target_name_match>%\.?)
% matches the character % literally (case sensitive)
\.
matches the character . literally (case sensitive)
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
5th Alternative
(?P<token_rule_sep>[:])
Named Capture Group token_rule_sep
(?P<token_rule_sep>[:])
Match a single character present in the list below
[:]
: matches the character : literally (case sensitive)
6th Alternative
(?P<incr_op>\n)
Named Capture Group incr_op
(?P<incr_op>\n)
\n matches a line-feed (newline) character (ASCII 10)
7th Alternative
(?P<line_end>\n)
Named Capture Group line_end
(?P<line_end>\n)
\n matches a line-feed (newline) character (ASCII 10)
8th Alternative
(?P<comment_op>#[.*]+$)
Named Capture Group comment_op
(?P<comment_op>#[.*]+$)
# matches the character # literally (case sensitive)
Match a single character present in the list below
[.*]
$ asserts position at the end of a line
9th Alternative
(?P<adjust_parser>[\$%\s\t\:])
Named Capture Group adjust_parser
(?P<adjust_parser>[\$%\s\t\:])
Match a single character present in the list below
[\$%\s\t\:]
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.

Regular Expression
No Match

r"
"
gm

Test String