欢迎光临
我们一直在努力

正则表达式格式-PHP教程,其它文章

建站超值云服务器,限时71元/月

正则表达式在php中被用来处理复杂的文字串。支持正则表达式的函数有:

ereg()

ereg replace()

eregi replace()

split()

这些函数都将正则表达式作为他们的第一个参数。php使用posix扩展规则表达式(使用posix 1003.2)。要找到所有的关于posix扩展规则表达式的描述,请查看包括在php发行版本之内的regex man页面。

example 2-4. regular expression examples

  ereg("abc",$string);

/* returns true if "abc"

is found anywhere in $string. */

ereg("^abc",$string);

/* returns true if "abc"

is found at the beginning of $string. */

ereg("abc$",$string);

/* returns true if "abc"

is found at the end of $string. */

eregi("(ozilla.[23]|msie.3)",$http_user_agent);

/* returns true if client browser

is netscape 2, 3 or msie 3. */

ereg("([[:alnum:]]+) ([[:alnum:]]+) ([[:alnum:]]+ )",

$string,$regs);

/* places three space separated words

into $regs[1], $regs[2] and $regs[3]. */

ereg_replace("^","<br>",$string);

/* put a <br> tag at the beginning of $string. */

ereg_replace("$","<br>",$string);

/* put a <br> tag at the end of $string. */

ereg_replace("\n","",$string);

/* get rid of any carriage return

characters in $string. */

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 正则表达式格式-PHP教程,其它文章
分享到: 更多 (0)

相关推荐

  • 暂无文章