HELP
HELP

Reputation: 14575

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

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_&; ]#', '', $abcd)

Upvotes: 4

Views: 3732

Answers (2)

Chandu
Chandu

Reputation: 82903

Add a + to the list.

preg_replace('#[^-a-zA-Z0-9_&; +]#', '', $abcd)

Upvotes: 0

Kyle
Kyle

Reputation: 2872

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

Upvotes: 5

Related Questions