Javascript
在 chrome console 中测试:
"bAseline".match(/\d*[A-Z]*|\?/) ["", index: 0, input: "bAseline", groups: undefined] 需求: regex = /\d*[A-Z]*|?/
3P 返回 3P
3 返回 3
Google 返回 G
GOogle 返回 GO
bAseline 返回 A
? 返回 ?
调用 string.match 方法!
const s = "bAseline"; const res = s.match(/\d*[A-Z]*|\?/); 如果 /\d*[A-Z]|?/ =》 /\d[A-Z]+|?/ 即把 A-Z 后面的*改成+号的话,bAseline 能够通过,但是 纯数字 比如 3 又不行了。
还是说,我不应该用这个方法?
谢谢!
