Common php regular expressions (1/9)

Source: Internet
Author: User
Tags ereg regular expression

<?
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/> ";
 }
}

 

Home 1 2 3 4 5 6 7 8 9 Last page
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.