What is a simple regular expression? Reply to score! The telephone number field (telvarchar type) stores three numbers and ends with a semicolon, for example, 0510-12323475,0781-26354589,021-25698746 (three numbers are stored simultaneously) 0521-25698745 ,, (It is possible to store only one phone number.) 0521 is a simple regular expression? Reply to score!
The telephone number field (tel varchar type) stores three numbers and ends with a semicolon, similar:
0510-12323475,0781-26354589,021-25698746 (three numbers are stored simultaneously)
0521-25698745, (it is possible to store only one phone number)
0521-25698745,021-25698475, (it is possible to store only two phone numbers)
Now, use regular expressions to determine whether the phone number is normal. pay attention to the telephone area number.
RegTel =/^ (\ d {3, 4}-\ d {7, 8} (-\ d {1, 4 })?)? $/I wrote this, but it does not work.
------ Solution --------------------
PHP code
$ Str = '1970-0510, '; $ pattern = '/,? \ D {4}-\ d + ,? /'; Var_dump (preg_match ($ pattern, $ str ));
------ Solution --------------------
PHP code
$ Ar = array ('2017-12323475,0781-0510-26354589,021 ', '2017-25698746,', '2017-0521-25698745 ', '2017-0521, ttttttt',); $ pattern = '/(? : \ D {3,}-\ d +, |,) {3}/'; foreach ($ ar as $ v) {$ v = trim ($ v ). str_repeat (',', 3-substr_count ($ v, ','); // complete the comma echo $ v. ''. preg_match ($ pattern, $ v), PHP_EOL ;}
------ Solution --------------------
Discussion
Boss, I only need the regular expression of $ pattern. But your $ pattern won't work.