How to find with regex the, of and a, but not a href

Having a question about translating phpBB 3.3? Want to discuss and collaborate with people currently translating phpBB 3.3? Here would be the correct place to do so.
leschek
Registered User
Posts: 863
Joined: Tue Jul 18, 2006 12:49 pm

How to find with regex the, of and a, but not a href

Post by leschek »

In Czech language we have typography rule, that prepositions shouldn't be on the end of the line. I tried to find out if it also applies in English, but I guess not, as I found about it this reddit post.

I would like to correct language pack to follow the rule and replace whitespace after prepositions with  

To make example for English speakers – I would like to find in language file (e.g. phpBB-3.3.12\phpBB3\language\en\install.php) following words (I will replace it later with Czech words):

the, of, a

I created the simple regular expression (for Notepad++):

Find: \b(the|a|of)\s

Replace with: $1 

and it seems to work, but it also find a href. So the question is, how to find with regex the, of, a but not a href?
User avatar
Gumboots
Registered User
Posts: 848
Joined: Fri Oct 11, 2019 1:59 am

Re: How to find with regex the, of and a, but not a href

Post by Gumboots »

🇺🇦 Слава Україні! 🇺🇦 Героям слава! 🇺🇦
leschek
Registered User
Posts: 863
Joined: Tue Jul 18, 2006 12:49 pm

Re: How to find with regex the, of and a, but not a href

Post by leschek »

Thank you. It helped. I had to find some explanation (here is the link), because I'm more than newby, but after a few hour I made string which seems to work:
\b(a(?!\shref)|the|of)\s
leschek
Registered User
Posts: 863
Joined: Tue Jul 18, 2006 12:49 pm

Re: How to find with regex the, of and a, but not a href

Post by leschek »

Aidy wrote: Sun Jul 21, 2024 10:42 amUse this pattern:
(?<!href=")\b(the|a|of)\s
Thank you, but it also matches the a in <a href="... which I don't want.

Return to “[3.3.x] Translations”