Home > Article > Backend Development > PHP regex - ignore whitespace
<?php /** * Created by PhpStorm. * User: Ollydebug * Date: 2015/11/15 * Time: 15:20 */ /* * U-懒惰匹配 * i-忽略英文字母大小写 * x-忽略空白 * s-让元字符' . '匹配包括换行符内所有字符 */ $pattern = '/Go Ogle.+123/Uix'; $subject = 'I love google__123123123123123123'; $matches = array(); preg_match($pattern,$subject,$matches); show($matches); function show($var){ if(empty($var)){ echo 'null'; }elseif(is_array($var)||is_object($var)){ // array,object echo '<pre class="brush:php;toolbar:false">'; print_r($var); echo ''; }else{ //string,int,float echo $var; } } ?>
The above introduces PHP regular expressions - ignore the blanks, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.