I'm trying to detect string variants: {ext_1} or {ext_1alpha} or {ext_aplpha1}
My regular expression: /{ext_(^[0-9,a-z]+$)}/gi
var arr = str.match(/{ext_(^[0-9,a-z]+$)}/gi);
But this is wrong. How can I solve this problem?
You have anchors (^ and $) in the middle of the regex where they can't ever match.
Use
/\{ext_([A-Z0-9]+)\}/gi
You also don't want a comma in your character class, unless you want to match actual comma characters in your string. Also, it's a good idea to escape curly braces because they can have special meaning in a regex.