Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve (input) {
- str = '';
- for (var index in input) {
- str += input[index];
- }
- str = str.replace(/\s/g,'');
- var anchors = str.match(/<a[^>]+>/g);
- var hrefs = [];
- for(var index in anchors) {
- if(anchors[index].match(/href\s*=\s*"[^"]+"/g)) {
- hrefs.push(anchors[index].match(/href\s*=\s*"[^"]+"/g).toString());
- }
- if(anchors[index].match(/href\s*=\s*'[^']+'/g)) {
- hrefs.push(anchors[index].match(/href\s*=\s*'[^']+'/g).toString());
- }
- }
- for(var index in hrefs) {
- if(hrefs[index].match(/="[^"]+"/g)) {
- console.log(hrefs[index].match(/="[^"]+"/g).toString().replace(/(=")|"/g, ''));
- }
- if(hrefs[index].match(/='[^']+'/g)) {
- console.log(hrefs[index].match(/='[^']+'/g).toString().replace(/(=')|'/g, ''));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement