【发布时间】:2011-04-28 16:58:49
【问题描述】:
在 PHP 中是否存在不需要使用正则表达式的 preg_match 等价物? str_replace() 对应 preg_replace。 preg_match 有什么东西吗。
*update * 我只是想用另一个替换一个已知的字符串。使用正则表达式似乎有点矫枉过正。
我有字符串“这是 [test1],而不是 [test2]”,我想将它们与“[test1]”和“[test2]”匹配。
【问题讨论】:
-
在需要正则表达式的地方你必须使用正则表达式
-
str_replace不等同于preg_replace。他们的目的不同。
标签: php preg-replace preg-match str-replace