-3

Regex testing for special characters, decimal except for hyphen, commas, alpha-numeric.

Attempt

^(\+|-)?([0-9]+)$/

I'm trying to write a regex to match special characters, decimal except for commas, a hyphen, alpha-numeric.

Community
  • 1
  • 1
Sucheta
  • 37
  • 1
  • 6

1 Answers1

0

Maybe, you might just want to list the chars that you wish in a [] and test it. Maybe, a simple expression like this would be desired for you and you could work on it:

^([?!"'~&%$*@#0-^@9]+)$

You might want to use this tool and design an expression that you wish, then test it with real samples and maybe change it as you wish.

enter image description here

You can also use an online visualizer to view how your expression would work:

enter image description here

Dharman
  • 30,962
  • 25
  • 85
  • 135
Emma
  • 27,428
  • 11
  • 44
  • 69