I would like to take a url and seperate it into mutliple parts so I can make a directory structure based on the url. I am still trying to wrap my head around regular expressions and I have also been looking into URI::URL but the answer is eluding me. Here is a little bit of what I have been trying:
The above example only gives me the directory part of the url and it is not split.use strict; use URI::URL; my $a = 'http://www.ash.com/ed/example/one.html'; my $url = URI::URL->new($a); my $path = $url->fragment(); print "$path \n";
my $ENTRY = "http://www.asd.com/123/456/789/"; $ENTRY =~ /http\:\/\/www\.asd\.com\/(\d+)\/(\d+)\/(\d+)\\"/; my($u_com, $name, $entry) = ($1, $2, $3); print "1 $u_com \n"; print "2 $name \n"; print "3 $entry \n";
This would be preferable, but I am not too sure about the regex parts. I think that the (d+) is reserved for just digits so I have also tried the above with (s+)but it does not work. I have been making my way through the Oreilly regular expressions book but I was hoping someone here would be nice enough to point me in the right direction.
Many Thanks,
ghettofinger
In reply to Splitting a url to make directories by ghettofinger
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |