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