Brutal 164 Posted September 1, 2014 Report Share Posted September 1, 2014 I could use some help if possible. I have a string: c:\user\thadude\directory\filename.ext That's just an example string - It would change constantly. What I am wanting is to use regex to remove everything except filename.ext There is no constant in the string - it will change per use, and per user, and the extension will change as well. Any help appreciated. Quote Link to post Share on other sites
UBotDev 276 Posted September 1, 2014 Report Share Posted September 1, 2014 Easy as this (use find regex function): (?<=\\)[^\\]+$ Quote Link to post Share on other sites
Brutal 164 Posted September 1, 2014 Author Report Share Posted September 1, 2014 set(#current_file_name, $find regular expression(#setfile, "(?<=\\).*?$"), "Global") UbotDev,thanks for the help man. - I tried it but it just leaves the var value empty. The variable - setfile has the big full path... and the variable current_file_name should end up with just the file name and ext. so c:\user\thadude\directory\filename.ext would become filename.ext Quote Link to post Share on other sites
Brutal 164 Posted September 1, 2014 Author Report Share Posted September 1, 2014 Ok, I got it figured out... You put me on the right path! Here's the regex code that works ([^\\/]+$) Quote Link to post Share on other sites
UBotDev 276 Posted September 1, 2014 Report Share Posted September 1, 2014 You were right, I corrected the regex above. Glad to hear you solved it. Quote Link to post Share on other sites
Brutal 164 Posted September 1, 2014 Author Report Share Posted September 1, 2014 Pass me a DONATE link uBotDev - I'm happy to buy you a cold one for all of the help you are always giving. Quote Link to post Share on other sites
UBotDev 276 Posted September 1, 2014 Report Share Posted September 1, 2014 Thanks for your generosity, but it's OK, I'm happy to help if on the receiving end they are willing to learn ....so just keep learning. If you still insist, I now have a donate button on my website. Quote Link to post Share on other sites
Brutal 164 Posted September 1, 2014 Author Report Share Posted September 1, 2014 Indeed I do insist :-) ... Donation made. Quote Link to post Share on other sites
UBotDev 276 Posted September 1, 2014 Report Share Posted September 1, 2014 Damn you are stubborn.... Thank you! Quote Link to post Share on other sites
Brutal 164 Posted September 2, 2014 Author Report Share Posted September 2, 2014 uniquebot - trying to wrap my head around what you're saying... just not happening right now.... definitely time for food and a little rest, then i'll come back and re-read it. 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.