preg_replace 方法

标红关键字

$text = "Sample sentence from KomunitasWeb, regex has become popular in web programming. Now we learn regex. According to wikipedia, Regular expressions (abbreviated as regex or
regexp, with plural forms regexes, regexps, or regexen) are written in a formal language that can be interpreted by a regular expression processor";
$text = preg_replace("/(regex)/", '<span style="background:#5fc9f6">\1</span>', $text);
echo $text;

  

posted on 2015-04-16 11:49  小V_chen  阅读(194)  评论(0编辑  收藏  举报

导航