If i have:
var x = "123442234535asd";
What regular expression would I have to use on x.split(regex); to get "asd"?
PS: x would always have a random string of numbers first and a string of letters after.
You can simply remove the digits:
var x = "123442234535asd";
x = x.replace(/\d+/, "");
console.log(x);
output:
asd
If you really need to split the string you can use:
var x = "123442234535asd";
x= x.split(/\d+/);
+ after the digit matching shortcut needed there? I was thinking global g was what was needed, but it turns out here that either works.x.split(/[0-9]+/);
the last element in the array would be 'asd'
If you want to split and only keep non-empty elements in the array that you get, use .filter(Boolean) after splitting:
var x = "123442234535asd";
alert(x.split(/[0-9]/g).filter(Boolean));
x.replace(/\d/g,'');[a-zA-Z]+?