模式修正符(Pattern Modifiers) i -可同时匹配大小写字母 M -将字符串视为多行 S -将字符串视为单行,换行符做普通字符看待,使“.”匹配任何字符 X -模式中的空白忽略不计 U -匹配到最近的字符串 e -将替换的字符串作为表达使用 格式:/apple/i匹配“apple”或“Apple”等,忽略大小写。 /i
preg_match()和preg_match_all()正则表达式的匹配 语法格式:if (preg_match ("/php/i", "PHP is the web scripting language of choice.")) { print "A match was found."; } else { print "A match was not found."; }
preg_quote()转义正则表达式字符 语法格式:$keywords = "$40 for a g3/400"; $keywords = preg_quote ($keywords, "/");//转义谁 /转义符号 echo $keywords;