在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
preg_filterpreg_grep<?php $array=array(1,2,3.4,53,7.9,.4); $fl_array=preg_grep("/^(\d+)?\.\d+$/",$array); print_r($fl_array);
preg_mactch_all<?php $userinfo = "Name: <b>PHP</b> <br> Title: <b>Programming Language</b>"; preg_match_all ("/<b>(.*)<\/b>/U", $userinfo, $pat_array); print_r($pat_array[0]); ?>
<?php //\\2是一个后向引用的示例. 这会告诉pcre它必须匹配正则表达式中第二个圆括号(这里是([\w]+)) //匹配到的结果. 这里使用两个反斜线是因为这里使用了双引号. $html = "<b>bold text</b><a href=howdy.html>click me</a>"; preg_match_all("/(<([\w]+)[^>]*>)(.*?)(<\/\\2>)/", $html, $matches, PREG_SET_ORDER); foreach ($matches as $val) { echo "matched: " . $val[0] . "\n"; echo "part 1: " . $val[1] . "\n"; echo "part 2: " . $val[2] . "\n"; echo "part 3: " . $val[3] . "\n"; echo "part 4: " . $val[4] . "\n\n"; } ?>
|
2022-08-18
2022-07-18
2022-08-17
2022-08-17
2022-11-06
请发表评论