in reply to Re^2: This regular expression has me stumped
in thread This regular expression has me stumped
:-D
Ok, let's take it a a little at a time:
s! you know, although it's possible you didn't know you can use pretty much any character for the expression delimiters.
(?:^|/) matches (without capturing) either the start of the string or a /.
[^\s,@;]* matches as many characters that aren't in the set of terminal characters as can be found.
(?<=/) looks back and asserts the last character matched was /.
([^\s,@;]+?) matches and captures as few non-terminal characters as it can and still find a match. That's the filename that you want.
(?=[\s,@;]|$) looks ahead and asserts that the next character is a terminal character or the end of the string.
!$1!g you are probably completely familiar with - replace all the matched stuff with the captured string and do it for every match that can be found.
So with a little head scratching the introductory line of my initial reply might make a more sense along with the regex. For further study consult perlretut, perlre and perlreref.
|
|---|