2 ms·
Python even supports this in its regex library, where it's called "verbose regexes". You'd write your code as def main(args): regexStr = \
by kqr 9y ago
Python even supports this in its regex library, where it's called "verbose regexes". You'd write your code as
def main(args):
regexStr = \
"""
\\b # begin match at word boundary
\\d{3} # match three digits
[-.]? # optional – match dash or dot
"""
if args[0].match(regexStr):
print("match")
else:
print("no match")
It's even better with nested structures, because it allows indentation as well!