code_junkie

Regular Expression to find all links in webpage

Nov 13th, 2011
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. <a href[^>]*>(.*?)</a>
  2.  
  3. StringCollection resultList = new StringCollection();
  4. try {
  5. Regex regexObj = new Regex("<a href[^>]*>(.*?)</a>", RegexOptions.IgnoreCase);
  6. Match matchResult = regexObj.Match(subjectString);
  7. while (matchResult.Success) {
  8. resultList.Add(matchResult.Value);
  9. matchResult = matchResult.NextMatch();
  10. }
  11. } catch (ArgumentException ex) {
  12. // Syntax error in the regular expression
  13. }
  14.  
  15. rex = /.*href="([^"]+)"/;
  16. a = source.replace(rex,'n$1').split('n');
  17.  
  18. a = REMatch('href="[^"]+"',source);
  19. for (i = 1; i < ArrayLen(a); i++) {
  20. a[i] = mid(a[i],6,len(a[i])-1);
  21. }
Add Comment
Please, Sign In to add comment