sifuhall 0 Posted May 13, 2013 Report Share Posted May 13, 2013 I'm trying to set a variable to a file name, not including path or extension. For example:I have c:\temp\test\myfile.xxxand I would like to set the variable #filename to myfile I've been trying for a while to get this with regex but I'm having difficulty. Can some of the regex pros here please help? Quote Link to post Share on other sites
HelloInsomnia 1103 Posted May 13, 2013 Report Share Posted May 13, 2013 Try this: (?<=(\\))[a-zA-Z0-9\-_]*\.\w+ 1 Quote Link to post Share on other sites
VaultBoss 310 Posted May 13, 2013 Report Share Posted May 13, 2013 This one would also remove the TLD from the file, if you want so: (?<=(\\))[a-zA-Z0-9\-_]*(?=\.) This way, your: c:\temp\test\myfile.xxx ----> myfile only... 1 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.