Php entry-level learning knowledge point 4 Basic PHP Regular Expression application _ php entry _ script house

Source: Internet
Author: User
Tags ereg php regular expression
Php entry-level learning knowledge point 4: Basic Application of PHP regular expressions, regular expressions are also commonly used in php. You must master them. No, you can go to the home page to view the basic regular expression materials.

Php entry-level learning knowledge point 4: Basic Application of PHP regular expressions, regular expressions are also commonly used in php. You must master them. No, you can go to the home page to view the basic regular expression materials.

The Code is as follows:
// Regular Expression
// Ereg case sensitive
If (ereg ("([A-Z] {3,})", "AAA ")){
Echo "matches in uppercase!
";
} Else {
Echo "no ";
}
If (ereg ("([A-Z] {3,})", "aaa ")){
Echo "yes ";
} Else {
Echo "lowercase letters cannot match!
";
}
// Eregi is case insensitive
If (eregi ("([A-Z] {3,})", "Aaaa ")){
Echo "can all be matched in uppercase and lowercase! ";
}
// Return the matched Value
If (ereg ("^ (0 [0-9] {2, 3})-([0-9] {7, 8})", "0592-5337138", $ regs )) {
Echo "Return Value 0 subscript is original string $ regs [0]
";
Echo "return area code (the first matching string)". $ regs [1]."
";
Echo ("Return phone number (second matching string) $ regs [2]
");
}
?>

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.