Ec (2); & nbsp; Code copy Code as follows $ str1-8732dsef83dfrese8732DEef83dfrESe; Have friends write like this & nbsp; copy the code var_dump (preg_match ([0-9] +-[a-zA-Z0-9] {32}, $ str); script ec (2); script
The Code is as follows: |
|
$ Str = '1-8732dsef83dfrese8732DEef83dfrESe '; |
// Some friends wrote this.
The Code is as follows: |
|
Var_dump (preg_match ('/[0-9] +-[a-zA-Z0-9] {32}/', $ str )); |
// Possible problems
The Code is as follows: |
|
$ Str = 'www1-8732dsef83dfrese8fdsfds3dfrESe-wfds111cn.netee '; $ Str = 'wwwfsdgwww. 111cn. netwww1-873dfsfds32DEef83dfrESe-weeee '; // Both forms are considered to be matched. // So you should change it Var_dump (preg_match ('/^ [0-9] +-[a-zA-Z0-9] {32} $/', $ str )); |
// The correct method is
The Code is as follows: |
|
Var_dump (preg_match ('/^ [0-9] +-[a-zA-Z0-9] {32} $/', $ str )); |
// Look at other regular expressions (Chinese characters, letters, and numbers)
/*
First Chinese character,
2-4 digits are letters,
5th Chinese characters,
6-14 digits are numbers,
The last character is a Chinese character.
*/
The Code is as follows: |
|
[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] $ |