Advertisement
Guest User

Extract Links

a guest
Oct 5th, 2016
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function validateLink(array){
  2.     let regex = /(www).([a-zA-Z0-9-]+)([.][a-z]*[a-z])+([.][a-z]*[a-z])*/g;
  3.     let result = [];
  4.     for(let sentence of array){
  5.         let match = sentence.match(regex);
  6.         if(match != null) {
  7.             for (let occurrance of match) {
  8.                 result.push(occurrance);
  9.             }
  10.         }
  11.     }
  12.     console.log(result.join('\n'));
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement