I'm trying to match groups of alphanumerics, optionally separated by the dash -.
For example,
ABCABC-DEF123-DEF-ABC
but not
--ABCABC-
I've managed to do this in the backend (Java) with \w+(\-?\w+)* which works well enough, but it doesn't seem to translate to JS. I've tried many permutations with various flag settings, to no avail.
What am I doing wrong? The unit tests can be found here. Setting the sticky flag seems to pass most tests, except for the ones with a dash at the end.
Thank you