I would like to set a variable to certain values based on what a searchtext starts with.
What I currently have:
var action;
switch (searchText.substr(0, 3).toUpperCase()) {
case 'ABC':
action = 'foo';
break;
case 'CDE':
action = 'bar';
break;
}
This works. But I would like to extend it so that instead of only checking if the text startswith ABC
it should be ABC
+ at least two numbers, like ABC12
. How would I make a regular expression inside my switch case that validates against that?