PHP从不包含@和的字符串中删除数字

PHP从不包含@和的字符串中删除数字,php,regex,Php,Regex,我尝试使用preg_replace,但它不能正确地工作,因为这些变量包含@,并且它们的数字也被删除了 例如@cv12->@cv12和cv12->cv尽管问题质量很差: $s = '@vc12'; // or whatever... // verify # and @ don't exist if (strpos($s,'@') === false && strpos($s,'#') === false) { // replace all numbers and store

我尝试使用preg_replace,但它不能正确地工作,因为这些变量包含@,并且它们的数字也被删除了


例如@cv12->@cv12和cv12->cv

尽管问题质量很差:

$s = '@vc12'; // or whatever...

// verify # and @ don't exist
if (strpos($s,'@') === false && strpos($s,'#') === false)
{
  // replace all numbers and store result back to variable
  $s = preg_replace('/\d/','',$s);
}
参考资料:

未找到$pinder时返回false 您可以使用$stringCheck=strops$stringToSearch,$searchPattern;$searchPattern将等于@,然后使用if$stringCheck==false removeNumbers$stringToSearch;就这么简单


如果有帮助,请告诉我。

您使用的代码在哪里?分享您的研究成果对每个人都有帮助。告诉我们您尝试了什么,以及为什么它不能满足您的需求。这表明你花了时间来帮助自己,它使我们避免重复显而易见的答案,最重要的是,它帮助你得到一个更具体和相关的答案!