0

I am trying to validate IDs for HTML 5, jQuery, and CSS

For HTML 5, it's pretty easy: basically just \S+. Yes, you do need one character, but in practice this is never an issue for me.

The problem is with jQuery. I need to weed out at least the apostrophe (') and quote (") characters, plus parenthesis '(' and ')'. When I try to use a jQuery selector like: #he(llo) it throws an Exception.

Right now I am validating my ids negatively in two steps. First, check for matches with '\s', then with the specific characters mentioned above.

I am just wondering if it is possible to do this in 1 regex - especially like "check for \S, plus..." ex. [\S\'\"\(\)]

PM 77-1
  • 12,933
  • 21
  • 68
  • 111
ControlAltDel
  • 33,923
  • 10
  • 53
  • 80

1 Answers1

2

wont something like this work

[^\s'"()]+
kunz
  • 1,063
  • 1
  • 11
  • 27