How can I check for a plus sign using regular expressions?

后端 未结 2 1686
Happy的楠姐
Happy的楠姐 2020-12-21 03:52

I\'m trying to check for a plus sign using PHP and regular expressions.

Here is the code I got so far.

preg_replace(\'#[^-a-zA-Z0-9_&; ]#\', \'\'         


        
相关标签:
2条回答
  • 2020-12-21 04:39

    Add a + to the list.

    preg_replace('#[^-a-zA-Z0-9_&; +]#', '', $abcd)
    
    0 讨论(0)
  • 2020-12-21 04:40

    You might just need to escape the plus sign with a backslash: \+.

    0 讨论(0)
提交回复
热议问题