我在试着拆开一个测试应用的科技缩略语
Array.from('CAPTCHA')
Gives me: ['C','A','P','T','C','H','A']
如果缩略语只是字母,效果很好。
但是..。
Array.from('AES256')
Gives me: ['A', 'E', 'S', '2', '5', '6']
我想把任何数目的团体放在一起。
e.g. ['A', 'E', 'S', '256']
对如何做到这一点有什么建议吗?
regex?
发布于 2019-10-25 22:09:28
可以将正则表达式与String.match()
结合使用。
const pattern = /[^0-9]|[0-9]+/g
console.log('CAPTCHA'.match(pattern))
console.log('AES256'.match(pattern))
https://stackoverflow.com/questions/58566307
复制相似问题