go ahead... be a heretic | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I wanted to substitute the extension of a filename by 'txt', that is to transform abc/xyz.something into abc/xyz.txt. This is easy, but maybe driven by the sudden thought that I'm becoming an old man as the years passed by without ever having tried a positive look behind regexp, I came up with the following silly solution: That is, substitute the longest string at the end of the filename which does not contain a period, but is preceded with one. Interestingly, this did not work - no substitution was taking place. In my case this is overkill, because I happen to know in my filename that there *is* a period, so I could have much easier written (this would however replace the complete filename with txt if it doesn't contain a period). Nevertheless I would like to know *why* my original solution has failed. Any suggestions?
-- Ronald Fischer <ynnor@mm.st> In reply to positive look behind regexp mystery by rovf
|
|