PHP Cheat Sheet: Regular Expression

1. preg_match(): if (preg_match(“/php/i”, “PHP is the web scripting language of choice.”)) {     echo “A match was found.”; } Note: $matches[0]will contain the text that matched the full pattern, $matches[1] will have the text that matched the first captured parenthesized subpattern, and so on. $str = http://www.php.net/index.html; if (preg_match(‘@^(?:http://)?([^/]+)@i’, $str, $matches) { $host = […]