Created
January 15, 2018 08:59
-
-
Save FreeFly19/a207afcd81510404233633ef18f7eac9 to your computer and use it in GitHub Desktop.
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) { | |
| 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