
PGScooter
stranger
Mar 14, 2008, 11:58 PM
Post #2 of 4
(299 views)
|
hi birdy, so I think you're asking how you can convert a string such as 'blah/blah/nameofpdf.pdf" to nameofpdf.pdf? Is that what you're asking? If so, regular expressions are your answer! if you want to do more research, look them up on google.
$file='blah/blah/blah/wantthis.pdf'; if ($file=~/(\w*\.pdf)/) { print $1; } A question if someone happens to see this. Why doesn't this code work?
$file='blah/blah/blah/wantthis.pdf'; if ($file=~/(\/\S*?pdf)/) { print $1; } Doesn't this correctly say: "find a forward slash followed by as many nonwhitespace characters until pdf"? And since I'm using a non-greedy operator, shouldn't it correctly just spit back wantthis.pdf? What am I missing? Hope that helps birdy, Scott The more you teach me, the more I learn. The more I learn, the more I teach.
|