andymurray 2 Posted May 14, 2013 Report Share Posted May 14, 2013 Hello, I'm trying to get just the filename of a string into a variable. Here is an example string:F:\IM Archive\Current\Software\Ubot\Projects\WPI\Product\LetsGoCamping_PLR\Main-Product\Mod 2- Website\images\TransparentLogo.gif So in this example I want just the 'TransparentLogo' without the .gif Thanks,Andy Quote Link to post Share on other sites
UBotDev 276 Posted May 14, 2013 Report Share Posted May 14, 2013 This should do it: (?<=\\)[^\\]*(?=\.\w*$) 1 Quote Link to post Share on other sites
andymurray 2 Posted May 14, 2013 Author Report Share Posted May 14, 2013 Hey thanks. That was real quick! I'll give it a whirl. Cheers,Andy Quote Link to post Share on other sites
andymurray 2 Posted May 14, 2013 Author Report Share Posted May 14, 2013 Yep! It works like a charm. Thanks again, saved me about 30 lines of tedious code over the bot Andy Quote Link to post Share on other sites
UBotDev 276 Posted May 14, 2013 Report Share Posted May 14, 2013 Np, glad I could help. 1 Quote Link to post Share on other sites
a2mateit 395 Posted May 15, 2013 Report Share Posted May 15, 2013 This should also do it. As long as it's always a .gif (?<=\\images\\).*(?=\.gif) 1 Quote Link to post Share on other sites
andymurray 2 Posted May 15, 2013 Author Report Share Posted May 15, 2013 Thanks a2mateit. But the file could be any type of image. ubotDev's solution word a treat. Andy Quote Link to post Share on other sites
Anonym 53 Posted May 15, 2013 Report Share Posted May 15, 2013 I want to help too If any image, then it could be (and just add the extensions that could be possible, e.g. tiff) (?<=\\)[^\\]*(?=\.(gif|bmp|jpg|jpeg)) Quote Link to post Share on other sites
andymurray 2 Posted May 15, 2013 Author Report Share Posted May 15, 2013 Thanks Anonym I'm writing down all these bits of code. Sure they'll come inhandy someday. Andy Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.