The application of regular expressions is mainly investigated from three aspects ( Basic metacharacters / Common regular expressions / use python re Module resolution )
\b
\B
\w
\W
\d
\D
\s
\S
.
*
+
?
|
Please search the above characters again , See what it means
This part of the expression is not unique , Because the needs are different .
^1[3-9]\d{
9}$
^1[^0-2]\d{
9}$
Blur the mobile phone number , Blur the middle four digits
import re
phone = '18728147811'
# \1 and \3 It refers to obtaining the matching value of the first group and the third group
res = re.sub(r"(\d{3})(\d{4})(\d{4})", r"\1****\3", phone)
print(res)
#187****7811
" for example [email protected]"
^[A-Za-z0-9_-][email protected][A-Za-z0-9_-]+(\.[A-Za-z0-9_-]+)+$
" Alphanumeric underscores support Chinese 4 To 12 position "
^[A-Za-z0-9\u4e00-\u9fa5_]{
4,12}$
Here are the password registration requirements for CET-4 and CET-6 website
"8-15 Bit length ( Case sensitive ); Password contains both : Capital 、 Lowercase letters 、 Numbers and special characters "
" Special characters are [email protected]#$%^&*-_"
^(?=.*\d+)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#%_-&\$\^\*])^.{8,15}$