-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path42.js
More file actions
29 lines (25 loc) · 720 Bytes
/
42.js
File metadata and controls
29 lines (25 loc) · 720 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// https://www.hackerrank.com/challenges/detect-html-links/problem
function processData(input) {
var r=/<a.*?href="(.*?)".*?>(.*?)<\/a>/ig;
var o=[];
input.replace(r,function(_,href,text){
o.push(href.trim()+','+text.replace(/<.*?>/g,'').trim())
});
console.log(o.join('\n'));
}
process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
process.stdin.on("data", function (input) {
_input += input;
});
process.stdin.on("end", function () {
processData(_input);
});
/*
import re
for z in range(int(input())):
html = input()
r = re.findall(r'<a href="(.*?)".*?>([\w ,./]*)(?=</)', html)
for link, title in r: print("{},{}".format(link, title.strip()))
*/