tommie Posted August 20, 2004 Share Posted August 20, 2004 ok :ninja: i'm no pro at regular expressions or anything but this is what i have: <\s*a\s*.*href\s*=\s*(?:\"(?<url>[^\"]*)\"|(?<url>\S+)).*>(?<name>.+)</a> all i know is that it works, somewhat. it's for extracting links, and grouping the url + name. it only works with links that are like link 1 link 2 link 3 doesn't work when they're all on one line like link 1 link 2 link 3 how do i make it stop on the first </a> tag? for when i get links that are all on one line. Link to comment Share on other sites More sharing options...
0 azcodemonkey Posted August 20, 2004 Share Posted August 20, 2004 Are you trying to execute this in .NET? Link to comment Share on other sites More sharing options...
0 tommie Posted August 20, 2004 Author Share Posted August 20, 2004 yeah for .net, what i put in the code tag is what i put into Expresso, a program to test regular expressions Link to comment Share on other sites More sharing options...
0 tommie Posted August 20, 2004 Author Share Posted August 20, 2004 (edited) Woop nevermind, got it solved somewhat, using ? <\s*a\s*.*?href\s*=\s*(?:\"(?<url>[^\"]*)\"|(?<url>\S+?)).*?>(?<name>.+?)</a> nevermind, fixed! Edited August 20, 2004 by tommie Link to comment Share on other sites More sharing options...
0 azcodemonkey Posted August 20, 2004 Share Posted August 20, 2004 Cool. I ended up not having time to work it out. I'm glad you got it. :D (Y) Link to comment Share on other sites More sharing options...
0 tommie Posted August 20, 2004 Author Share Posted August 20, 2004 (edited) Nevermind again haha this regex stuff is interesting. Had another problem got that working though. Edited August 20, 2004 by tommie Link to comment Share on other sites More sharing options...
0 tommie Posted August 20, 2004 Author Share Posted August 20, 2004 Ok well, 1 problem now: <\s*a\s*.*?href\s*=\s*(?:\"(?<url>[^\"]*)\"|(?<url>[^\S]*)).*?>(?<name>.*?)</a> Links that aren't quoted (href=blahblah) aren't added to the url group, anybody know what's wrong ??? Link to comment Share on other sites More sharing options...
0 tommie Posted August 21, 2004 Author Share Posted August 21, 2004 Got it again, <\s*a\s*.*?href\s*=\s*(?:\"(?<url>[^\"]*)\"|(?<url>[^\s>]*)).*?>(?<name>.*?)</a> Link to comment Share on other sites More sharing options...
0 Sn1p3t Posted August 21, 2004 Share Posted August 21, 2004 BTW: www.regexlib.com is a good site if you dont' have the time / expertise to construct a particular regular expression. Link to comment Share on other sites More sharing options...
Question
tommie
ok :ninja: i'm no pro at regular expressions or anything but this is what i have:
all i know is that it works, somewhat. it's for extracting links, and grouping the url + name. it only works with links that are like
link 1
link 2
link 3
doesn't work when they're all on one line like
link 1 link 2 link 3
how do i make it stop on the first </a> tag? for when i get links that are all on one line.
Link to comment
Share on other sites
8 answers to this question
Recommended Posts