Skip to main content
2 of 8
edited tags; edited title
200_success
  • 145.6k
  • 22
  • 191
  • 481

Regex to validate font names

/((([\w -]+)|("[\w -]+"))( *, *)?)+/

http://refiddle.com/18ql

I'm trying to use a regex to sanitize a user input for a list of fonts. The above one seems to work nicely, but also feels a bit long and redundant, having two [\w -]*s, and allowing a trailing comma, and possibly stuff I can't see. Can this be more efficient (smaller, less redundant, more secure)?


Also, I think an input, input-handling, andor input-sanitization tag would be good additions to this SE.

Ky -
  • 407
  • 2
  • 15