A text to understand the relationship between metacharacters, escape characters and operators (regular expressions)

Metacharacter introduction:

This is a metacharacter table that you can also use to learn regular expressions:Insert picture description here

Understanding the relationship between metacharacters and escape characters

I saw a sentence in the book:
Insert picture description hereThe purpose of this article is to give you a deeper understanding of this sentence, please see the following analysis:
Insert picture description here

Operator:

Insert picture description here

The above is my personal understanding, I hope it can help you, and I welcome refutation.

and also

tel = '''00-111,11-222,22-333'''
pattern = re.compile(r'(\d{2})-(\d{3})')
print(pattern.findall(tel))

pattern = re.compile(r'\d{2}-\d{3}')
print(pattern.findall(tel))

Can anyone explain why the two pieces of code return different, why the above can return, I think it does not match

Guess you like

Origin blog.csdn.net/jokerxsy/article/details/106216590