0

I have this: [0-9a-z]

which matches a character that's a number or lowercase letter. If I wanted to match all alphanumerics I could do: [0-9a-zA-Z], but I am simply wondering if there is shorthand to match all alphanumerics?

  • 2
    Use the `/i/` modifier in your pattern. – Tim Biegeleisen May 14 '19 at 01:10
  • i couldn't use `/i` for the whole regex, just for the groups –  May 14 '19 at 01:11
  • 1
    There is no way to make a fragment of a pattern lowercase, only the entire pattern. – Tim Biegeleisen May 14 '19 at 01:12
  • 1
    Many flavors of regex have special character classes like `[[:alnum:]]` which does exactly what you're asking for, but this isn't available in javascript's regex. However. there's the "word" character class `\w`, which matches `[a-zA-Z0-9_]`. If false positives on underscores aren't a concern, this is what you're looking for. – CAustin May 14 '19 at 01:12
  • yeah I don't want to match underscores, but thanks I might be able to use that –  May 14 '19 at 01:13

0 Answers0