Sign in to follow this  
Followers 0
AutID

Regex pattern

3 posts in this topic

#1 ·  Posted (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 by AutID

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0