Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save saiberz/13b850b8d5a660b3f32f52adf2d0d74c to your computer and use it in GitHub Desktop.
Save saiberz/13b850b8d5a660b3f32f52adf2d0d74c to your computer and use it in GitHub Desktop.
Hacker Rank Regex
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