Created
August 3, 2019 03:28
-
-
Save saiberz/13b850b8d5a660b3f32f52adf2d0d74c to your computer and use it in GitHub Desktop.
Hacker Rank Regex
This file contains hidden or 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 [other, ...numbers] = input.split("\n") | |
console.log({ input }); | |
console.log({ numbers }); | |
numbers.map(x => isValid(x)); | |
} | |
function isValid(number) { | |
var re = /^\([\+\-]?((?:[1-9]\d{1,2})(?:\.\d+)?)\, [\+\-]?((?:[1-9]\d{1,2})(?:\.\d+)?)\)$/g; | |
var response = number.match(re); | |
console.log({ response }); | |
} | |
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