Square brackets in a regular expressions with Python

0
40

We use re.match() to check if an input string matches with a pattern or not.
For example: pattern = ‘[DB]a[ng]s’
The input string matches with this pattern if:
1. It starts with D or B character
2. The second character is a
3. The third character is n or g
4. The last character is s

source

LEAVE A REPLY

Please enter your comment!
Please enter your name here