replace everything after the first occurrence of)

A swapping-ground for Regular Expression syntax

replace everything after the first occurrence of)

Postby lcastanheiro » Wed Jul 24, 2019 5:49 pm

Hello i have several movie files that are named something like this
Never Look Away (2018) - Drama, Thriller, History
I want to rename it to
Never Look Away (2018)
I entered the following
RegEx(1)
Match: (.+)\)
Repla: \1

But instead of getting Never Look Away (2018) it also deletes the last ")" and i get Never Look Away (2018. I want to keep the last )

Thanks for your help
lcastanheiro
 
Posts: 1
Joined: Wed Jul 24, 2019 5:38 pm

Re: replace everything after the first occurrence of)

Postby therube » Wed Jul 24, 2019 9:16 pm

Your match for \1 matches anything up to the character before the (final, as it is) ')'.

So include \) within your \1 match.

Code: Select all
Match:  (.+\))


If you wanted to make it non-greedy:
Code: Select all
Match:  (.+?\))
therube
 
Posts: 1317
Joined: Mon Jan 18, 2016 6:23 pm


Return to Regular Expressions