<?php/** * PHP regular function Learning * * The original ereg and EREGI functions have been discarded, the current version with Preg_match instead of * * Preg_match in the general use of the process to give three parameters, itself returns whether the match to the result 0 1. The third parameter is an array that matches the string to the array. * It matches until after the match is not continued, * * Preg_match_all matches to continue to match, returns the total number of matches, and the array contains all the matching strings. * * Ignore case not alone to function, after the regular string with I * * PHP's regular need to use//include * * * Regular replacement: Preg_replace generally give three parameters, return the replaced string. * * * /$str = ' JL history hi '; $s = preg_match_all ('/hi/i ', $str, $matches);//Ignore case, match to the number of times $s , The matched string is put into $matches//var_dump ($matches);//var_dump ($s); $ss = preg_replace ('/hi/i ', ' hello ', $str); Var_dump ($SS);? >
PHP Regular Function Learning