AutID Posted March 28, 2015 Share Posted March 28, 2015 (edited) Hello, I have some random paths and i want to get the file at the end of the path. The paths look like this: C:UsersrandomDesktoprandom1random1 updateupdated123whaeverbinyesDirectoryrandomSong.mp3 Which is the pattern to get only this; randomSong.mp3? Or even better this: randomSong. Sorry but i am really bad at regex. Edited March 28, 2015 by AutID https://iblockify.wordpress.com/ Link to comment Share on other sites More sharing options...
iamtheky Posted March 28, 2015 Share Posted March 28, 2015 (edited) $sString = "C:\Users\random\Desktop\random1\random1 update\updated\123\whaever\bin\yes\Directory\randomSong.mp3" $aString = stringsplit($sString , "\") msgbox(0, '' , stringtrimright($aString[$aString[0]] , 4)) or $sString = "C:\Users\random\Desktop\random1\random1 update\updated\123\whaever\bin\yes\Directory\randomSong.mp3" msgbox(0, '' , stringregexp($sString , ".*\\(.+)\.mp3" , 3)[0]) Edited March 28, 2015 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
AutID Posted March 30, 2015 Author Share Posted March 30, 2015 I was thinking about a stringsplit and a for loop to uboun the array and check for the .mp3 at the end and get the result but that's a lot of trouble for nothing. I like your regex. Thanks https://iblockify.wordpress.com/ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now