Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1.  
  2. console.log("Вывод результата использоввания регулярки на URL" + "\n");
  3. let url = " http://agemagic.ru.ru/age/dgdgd.ru даьыда http://example.example/example/example.example";
  4. let arrayUrl = [];
  5. let regexUrl = new RegExp('(http(s)?:\\/\\/)(\\b\\w*\\b)((\\.\\b\\w*\\b)+)((\\/\\b\\w*\\b)*)(\\.\\b\\w*\\b)?(\\/)?', 'g');
  6. https://pastebin.com/K8FhxRve
  7. arrayUrl = Array.from(url.matchAll(regexUrl));
  8.  
  9. for (let i = 0; i < arrayUrl.length; i++){
  10. console.log(arrayUrl[i][0] + "\n")
  11. }
  12.  
  13. console.log("\n\n" + "Вывод результата использоввания регулярки на Email" + "\n");
  14.  
  15. let email = " \n" +
  16. "tes-t@mail.ru.t.gdgdg.d.fgd.fgd\n" +
  17. "\n" +
  18. "RegExr was created by gskinner.com, and is proudly hosted by Media Temple. \n" +
  19. "to you\n" +
  20. "Edit the Expression & ./csdfds .Ttes-t@mail.ru.t.gdgdg.d.fgd.fgdext to see matches. Roll over matches or the expression for details. PCRE & Javascript flavors of RegEx are supported.\n" +
  21. "http://example.example/example/example.example адпьвдврb,mh.gdh\n" +
  22. "The side bar includes a Cheatsheet, full Reference, and Help. You can also Save & Share with the Community, and view patterns you create or favorite in My Patterns.\n" +
  23. "\n" +
  24. "Explore results with the Tools below. Replace & List output custom results. Details lists capture groups. Explain describes your expression in plain English.\n" +
  25. "\n" +
  26. "hello.";
  27. let arrayEmail = [];
  28. let regexEmail = new RegExp('(\\w|-|_)*@(\\w|-|_)*(\\.\\b\\w*)*', 'g');
  29. arrayEmail = Array.from(email.matchAll(regexEmail));
  30.  
  31. for (let i = 0; i < arrayEmail.length; i++){
  32. console.log(arrayEmail[i][0] + "\n");
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement