PHP替代正则匹配的高效函数

strpos() - 查找字符串首次出现的位置

strrpos() 函数查找字符串在另一字符串中最后一次出现的位置(区分大小写)。

strripos() 函数查找字符串在另一字符串中最后一次出现的位置(不区分大小写)。

strstr() - 函数搜索字符串在另一字符串中的第一次出现,区分大小写。

http://www.runoob.com/php/func-string-strstr.html

strpbrk(a,b)-字符串a中查找b的字符

<?php

$text = 'This is a Simple text.';

// 输出 "is is a Simple text.",因为 'i' 先被匹配
echo strpbrk($text, 'mi');

// 输出 "Simple text.",因为字符区分大小写
echo strpbrk($text, 'S');
?>

 strncasecmp() 函数比较两个字符串(不区分大小写)。

 

posted @ 2016-11-11 15:54  简庆旺  阅读(1240)  评论(0编辑  收藏  举报