<?
1. Use the ereg function.
2. Usage example of the eregi () function.
3. Replace the matched string.
4. Replace the matching string with eregi_repalce.
5. Use the function split ().
6. Use the split () function.
7. The SQL _regcase () function generates a regular expression.
8 Example of regular expression function preg_grep.
9 Use the preg_match () function to perform regular expression matching.
10 match the application of the function preg_match_all.
11 expression search and replacement function preg_repalce ().
12. Use a regular expression to separate strings.
13. Example 1 of the regular expression used to check the IP address.
14. Example 2 of the regular expression used to check the IP address.
15. Match Chinese strings.
16 email regular expression.
17. url regular expression.
*/
// 1. Example of using the function ereg.
| The code is as follows: |
Copy code |
|
$ Arr_date = array (
'2017-06-01 ',
'2017-0x-10 ',
'12-12-12 ',
'2017-12-25 00:10:20 ',
'2017-2007'
);
For ($ I = 0; $ I <5; ++ $ I)
{
$ Date = $ arr_date [$ I];
If (ereg ("([0-9] {4})-([0-9] {1, 2})-([0-9] {1, 2 })", $ date, $ regs ))
{
Echo "the date string $ date conforms to the 'yyyy-mm-DD' format :";
Echo "$ regs [1]. $ regs [2]. $ regs [3] <br/> ";
}
Else
{
Echo "<B> The date string $ date does not conform to the date string in 'yyyy-mm-DD' format </B> <br/> ";
}
} |