Home Ask Login Register

Developers Planet

Your answer is one click away!

Sindu_ February 2016

Regex to allow only numbers, hyphens, brackets, plus sign and spaces

I am trying to form a regex that will allow only numbers, hyphens, brackets, plus sign and spaces can be found anywhere. Here are some examples:

(90990)-121332
(13)920298-232
897897-8098
+988 8892 222
987878798798
4234232211

Answers


Thanga February 2016

The below expression will do that

 [\d\-\)\(\+ ]+


ndn February 2016

^[\\d() +-]+$
  • ^ from the start of the string
  • $ til the end
  • \\d digit
  • () +- brackets, space, plus or dash
  • []+ one or more of those

Post Status

Asked in February 2016
Viewed 2,113 times
Voted 4
Answered 2 times

Search




Leave an answer


Quote of the day: live life