I need a regex pattern to split a string into numbers and letters. That is, .1abc2.5efg3mnoit should be divided by [".1","abc","2.5","efg","3","mno"].
My current regex is:
var str = ".1abc2.5efg3mno";
regexStr= str.match(/[a-zA-Z]+|[0-9]+(?:\.[0-9]+|)/g);
The result obtained:
["1","abc","2.5","efg","3","mno"]
The number is .1taken for 1, while I need it as .1.
source
share