题解 | #字符串通配符#
字符串通配符
https://www.nowcoder.com/practice/43072d50a6eb44d2a6c816a283b02036
const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;
void async function () {
// Write your code here
while(line = await readline()){
const line2 = await readline()
let reg = line.replace(/\*/g,'[A-Za-z\\d]*').replace(/\?/g, '[A-Za-z\\d]')
reg = new RegExp('^'+reg+'$','i')
console.log( reg.test(line2))
}
}()
使用 RegExp将字符串转换为正则表达式,通过第二个参数‘i'使得正则表达式对大小写不敏感