Trouble Grouping to First Group Only

A swapping-ground for Regular Expression syntax

Trouble Grouping to First Group Only

Postby swingking03 » Fri Apr 21, 2023 7:31 pm

I will preface this by saying that my regex knowledge is limited to the last hour of reading the manual vol. 2. I am trying to group a string into two groups:

1 = everything before a specific character
2 = everything after that specific character

Example:
Metallica-Enter Sandman-1991.mp3
to
Metallica.mp3

I have used:
Match: (^.+)-(.*)
Replace: \1

but it appears to be grouping from the last hyphen rather than the first, resulting in:
Metallica-Enter Sandman.mp3


How do i get it to group on the first instance of the hypehn?
swingking03
 
Posts: 8
Joined: Thu May 12, 2022 2:22 am

Re: Trouble Grouping to First Group Only

Postby swingking03 » Fri Apr 21, 2023 9:14 pm

Got it

(.*?)-(.*)
swingking03
 
Posts: 8
Joined: Thu May 12, 2022 2:22 am


Return to Regular Expressions