Created
March 21, 2016 22:59
-
-
Save jianminchen/7bdc395289554ca1c779 to your computer and use it in GitHub Desktop.
Two string - JavaScript - RegExp expression
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function processData(input) { | |
var data = input.split('\n'); | |
for (var i = 1; i < data.length; i += 2) { | |
var pattern = '[' + data[i] + ']'; | |
var reg = new RegExp(pattern); | |
console.log(reg.test(data[i+1]) ? 'YES' : 'NO'); | |
} | |
} | |
process.stdin.resume(); | |
process.stdin.setEncoding("ascii"); | |
_input = ""; | |
process.stdin.on("data", function (input) { | |
_input += input; | |
}); | |
process.stdin.on("end", function () { | |
processData(_input); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment