Regular Expressions 101

Community Patterns

Basic grammar for regex matching of simplistic Makefiles

-2

Regular Expression
Python

r"
(?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

Description

This expression should both normal and wildcard targets and rules wrapped in simple sub-shell or varriable substitution enclosures.

Submitted by Robert Butler <me@r-butler.net> - 10 years ago