[Python] Regex

Tags to use

Element Description
. This element matches any character except \n
\d This matches any digit [0-9]
\D This matches non-digit characters [^0-9]
\s This matches whitespace character [ \t\n\r\f\v]
\S This matches whitespace character [^ \t\n\r\f\v]
\w This matches alphanumeric character [a-zA-Z0-9]
\W This matches any non-alphanumeric character [^a-zA-Z0-9]

Quantifiers to use

Quantifier Description Example Sample match
+ one or more \w+ ABCDEF097
{2} exactly 2 times \d{2} 01
{1,} one or more times \w{1,} smiling
{2,4} 2 to 4 times \w{2,4} 1234
* 0 or more times A*B AAAAB
? once or none (lazy) \d+? 1 in 12345