我需要正则表达式模式将字符串拆分为数字和字母.即.1abc2.5efg3mno应分为[".1","abc","2.5","efg","3","mno"].
我试过的当前正则表达式是:
var str = ".1abc2.5efg3mno";
regexStr= str.match(/[a-zA-Z]+|[0-9]+(?:\.[0-9]+|)/g);
Run Code Online (Sandbox Code Playgroud)
获得的输出是:
["1","abc","2.5","efg","3","mno"]
Run Code Online (Sandbox Code Playgroud)
这个数字.1被视为1而我需要它.1.