How to get only a filename (not full path) into $1, using the PERL, regular expressions
- by Scott
I want to keep only the filenames (not full paths) and add the filename to some bbcode.
Here is the HTML to be converted:
<a href=/path/to/full/image.jpg rel=prettyPhoto><img rel=prettyPhoto src=/path/to/thumb/image.jpg /></a>
Notice I cannot have rel="foo" (no double quotes)..
Here is what I have in PERL, to perform the conversion:
s/\<a href=(.+?)\ rel=prettyPhoto\>\<img rel=prettyPhoto src=(.+?) \/>\<\/a\>/\[box\]$1\[\/box\]/gi;
This converts the HTML to:
[box]/path/to/image.jpg[/box]
But this is what I want as a result:
[box]image.jpg[/box]
The HTML must remain the same. So how do I change my PERL so that $1 contains only the filename?