Grouping?

A swapping-ground for Regular Expression syntax

Grouping?

Postby koberulz » Tue Apr 08, 2025 7:35 pm

I have a number of MKV files, all named "Archival $NameOfSubject.mkv". They have subtitle files, named "Archival $NameOfSubject.en.srt". They also have artwork generated by my media server, named "Archival $NameOfSubject-poster.jpg". I want to append aspect ratio to the end of the video's filename, and update the artwork and subtitles to match. My understanding is that this should work:

Match: (Archival)(.*)(\.en|\.en|-poster|-320-10|$)
Replace: \1\2 - 1.33\3

But it doesn't. The " - 1.33" just gets appended to the end of the filenames. So instead of "Archival Lisbeth Movin - 1.33-poster.jpg" I get "Archival Lisbeth Movin-poster - 1.33.jpg", which won't work. Replacing "(Archival)(.*)" with "()" in the "Match" field works, but it matches to everything in the folder instead of just the archival interviews.
koberulz
 
Posts: 1
Joined: Tue Apr 08, 2025 7:29 pm

Re: Grouping?

Postby TheGhost78 » Tue Apr 08, 2025 10:30 pm

(Archival)(.*)(\.en|-poster|-320-10)|$
TheGhost78
 
Posts: 173
Joined: Fri Jul 19, 2024 11:25 am

Using .*? to minimize matching

Postby Luuk » Sat Apr 12, 2025 11:47 am

The "Match" and "Replace" can also be like...
(Archival.*?)(\.en|-poster|-320-10|$)
\1 - 1.33\2

The .*? keeps Group-1 from matching .en/-poster/-320-10, since Group-2 would then match $...
Archival $NameOfSubject -----------> Archival $NameOfSubject - 1.33
Archival $NameOfSubject.en -------> Archival $NameOfSubject - 1.33.en
Archival $NameOfSubject-poster ---> Archival $NameOfSubject - 1.33-poster
Luuk
 
Posts: 803
Joined: Fri Feb 21, 2020 10:58 pm


Return to Regular Expressions