in reply to Re: REGEX for url
in thread REGEX for url
Thank you for your help! That expression does not seem to bind to anything for me, something else perhaps that I"m doing wrong? Below is a small amount of the code. Thanks again!
$/="</html>"; while (my $line = <$FH_IN>) { chomp $line; #removes line break or new line; my $url_sub = ""; my $data=""; $url_sub =~ s/.*a href="(.*)".*/$1/; print $url_sub;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: REGEX for url
by james28909 (Deacon) on Apr 25, 2016 at 20:57 UTC | |
Output:
EDIT: It seems that $/ = "</html>"; manipulates the input record seperator in such a way it does completely break the functionality of the simple regex. Do yu have any links to documentation on this $/ = "</html>"; ? | [reply] [d/l] [select] |
by wrkrbeee (Scribe) on Apr 25, 2016 at 21:28 UTC | |
Not sure if this helps, but the full text block, from <html> through </html> appears below. Just using $/ as a way to indicate the end of a record. I apologize for wasting your time.
| [reply] [d/l] |
by Marshall (Canon) on Apr 25, 2016 at 22:24 UTC | |
| [reply] [d/l] |
by wrkrbeee (Scribe) on Apr 25, 2016 at 21:09 UTC | |
| [reply] |
by NetWallah (Canon) on Apr 25, 2016 at 21:19 UTC | |
It can also handle multiple URL's.
This is not an optical illusion, it just looks like one. | [reply] [d/l] |
by ExReg (Priest) on Apr 25, 2016 at 22:07 UTC | |
Not able to check it on my machine, but wouldn't a /s be helpful here to be able to pass over the newlines? print if s/.*a href="(.*)".*/$1/s; | [reply] [d/l] |