php 什么是 preg_match 但不需要正则表达式?

Bro*_*ias 1 php preg-replace preg-match str-replace

在 PHP 中是否有preg_match不需要使用正则表达式的等价物?还有str_replace()preg_replace。有什么东西可以preg_match

*更新 *我只想用另一个替换已知字符串。使用正则表达式似乎有点矫枉过正。

我有字符串“这是[test1],而不是[test2]”,我想将它们与“[test1]”和“[test2]”匹配。

web*_*ave 5

如果您的意思是在不使用正则表达式的情况下在另一个字符串中查找字符串,则可以使用strpos

if (strpos('hello today', 'hello') !== false) {
    // string found
}
Run Code Online (Sandbox Code Playgroud)