How can I get only 'ABCD' from string 'ABCD150117T15' in java script.
I would like strip rest of the string from 'ABCD' in this example and generally everything until but excluding the first number character.
thanks
Use regex then to match the first digit, and then subtring it to the text;
var str = 'ABCD150117T15';
var index = str.search(/\d/);
var text = str.substr(0,index);
index and not index+1? (I'm not familiar with str.search)'ABCD150117T15'.match(/^\D+/)[0]
This would give you everything until the first number then :)
.substringfunction on string.