Skip to content

Instantly share code, notes, and snippets.

@FreeFly19
Created January 15, 2018 08:59
Show Gist options
  • Save FreeFly19/a207afcd81510404233633ef18f7eac9 to your computer and use it in GitHub Desktop.
Save FreeFly19/a207afcd81510404233633ef18f7eac9 to your computer and use it in GitHub Desktop.
function processData(input) {
const r = /<a.*href\s*=\s*["']([^"']*)["'][^>](.*)<\/a>/;
console.log(r);
const text = input
.split(/\n/)
.slice(1)
.join('')
.split(/<\s*a[\s]/)
.map(s => '<a ' + s)
.forEach(l => proc(r, l));
}
function proc(r, text) {
const t = r.exec(text);
if (t) {
const url = t[1];
const text = />(<.*>)*(.*)(<.*>)*/.exec(t[2]);
console.log(url + ',' + text[1]);
}
}
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