The code is as follows |
Copy Code |
$str = ' 1-8732dsef83dfrese8732deef83dfrese '; |
It's written by a friend.
The code is as follows |
Copy Code |
Var_dump (Preg_match ('/[0-9]+-[a-za-z0-9]{32}/', $str)); |
Problems that may exist
The code is as follows |
Copy Code |
$str = ' www1-8732dsef83dfrese8fdsfds3dfrese-wfds111cn.netee '; $str = ' wwwfsdgwww.111cn.netwww1-873dfsfds32deef83dfrese-weeee '; Both of these forms will be considered to be matched. So you should change it into Var_dump (Preg_match ('/^[0-9]+-[a-za-z0-9]{32}$/', $str)); |
The right way is
The code is as follows |
Copy Code |
Var_dump (Preg_match ('/^[0-9]+-[a-za-z0-9]{32}$/', $str)); |
Look at other methods of regular expressions (Chinese characters, letters, digital hybrid validation)
/*
First Chinese characters,
2-4 digits for the letter,
The 5th Digit Chinese character,
6-14 digits for the number,
The last one is Chinese characters
*/
The code is as follows |
Copy Code |
[U4e00-u9fa5] {1} [A-za-z] {2,4} [U4e00-u9fa5] {5} [0-9] {6,14} [U4e00-u9fa5] {1} ^[u4e00-u9fa5uf900-ufa2d][a-za-z]{3}[u4e00-u9fa5uf900-ufa2d]d{9}[u4e00-u9fa5uf900-ufa2d]$ |