I need help with a regex problem I don't understand. Luuk?

Bulk Rename Utility How-To's

I need help with a regex problem I don't understand. Luuk?

Postby Ronstang » Tue Feb 17, 2026 9:07 am

I cannot find an answer to this issue anywhere and here I have always received solid help solving my issues in renaming things. I am not using BRU to do this but since the principle is exactly the same I was wondering if anyone could help me solve this issue?

I'm working with subtitles here where entire lines have an apostrophe at the beginning and at the end of the line and I want to change all text bounded by these apostrophes into italics. I have the replace expression that works, I just cannot get the find expression correct.

It needs to identify the first apostrophe as having no text characters before it and the last apostrophe as one with no text characters after it but then I don't know how to handle something like (parents') as a word in the sentence. Plus it needs to ignore apostrophes in contractions because they are not the beginning or end of a line of text.

Some I have tried don't see past the line breaks either and I do not have enough understanding to figure that out at all.

Examples:

the famous homes<br />of New York's Fifth Avenue.
Needs to become

<i>the famous homes<br />of New York's Fifth Avenue.</i>
I have tried the following find expressions:

([^']+)
but it stops at the apostrophe in "York's" and then moves on to the next line

^'(.*?)'$
This one works when there is only one line but if there is a line break it skips that whole text string. This one completely skips the subtitle line I posted above because it has a line break.

So essentially if I could get this one to notice the line break within the single subtitle line itself it would work, but I don't really understand what is going on here.

Thanks for any help. I wish I understood this stuff better but I am not a programmer....but I can fix your car!
Ronstang
 
Posts: 48
Joined: Tue Feb 09, 2021 2:14 am

Re: I need help with a regex problem I don't understand. Luuk?

Postby Ronstang » Tue Feb 17, 2026 10:57 am

I figured it out:

Find: (?s)^'(.*?)'$

Replace: <i>$1</i>

Google isn't always useless, but I still don't understand it!!!
Ronstang
 
Posts: 48
Joined: Tue Feb 09, 2021 2:14 am

Re: I need help with a regex problem I don't understand. Luuk?

Postby Ronstang » Tue Feb 17, 2026 10:57 am

I figured it out:

Find: (?s)^'(.*?)'$

Replace: <i>$1</i>

Google isn't always useless, but I still don't understand it!!!
Ronstang
 
Posts: 48
Joined: Tue Feb 09, 2021 2:14 am


Return to How-To