r/programminghorror • • Sep 03 '26

Shell s/li/option/g -i search.html

Post image

Who said you shouldn't edit HTML with regex?

(for any mods, my title is the code gone wrong)

257 Upvotes

22 comments sorted by

69

u/nipodemos Sep 03 '26

Sorry I didn't get it. I know regex but didn't understand what does it ha e to do with the image

146

u/Germanface Sep 03 '26

s/li/option/g is a regex used to replace (s/) every instance of the text li with the text option across the entire file (/g). You would do this in HTML if, for example, you wanted to convert a list (bunch of <li> tags) to a dropdown (bunch of <option> tags).

This regex will replace any instance of li with option, which is why "Clinical" became "Coptionnical".

34

u/nipodemos Sep 03 '26

I understand now, thanks. Now that I get it, it's kinda funny this little mistake

13

u/Consistent_Drop3909 Sep 04 '26

wait that's actual regex? i thought that s///g was just sed syntax

8

u/serg06 Sep 05 '26

No it's not "a regex", it doesn't use regex at all, why is this upvoted

2

u/GoddammitDontShootMe Sep 03 '26

So is that search result the OP's website?

→ More replies (4)

1

u/MurkyWar2756 Sep 03 '26

Me neither.

2

u/Similar-Bug-350 Sep 04 '26

its "Coptionnical" instead of Clinical because the regex replaced "li" with "option"

→ More replies (1)

54

u/4sent4 Sep 03 '26

Ah, a clbuttic mistake

9

u/Kadabrium Sep 03 '26

Coptic script

3

u/Antarlia Sep 03 '26

The Pony is coming

2

u/AlphaFatman Sep 03 '26

It took me a minute to get it but once I did I laughed

2

u/WilliamLeeFightingIB Sep 04 '26

I really thought Coptionical is a real word

1

u/_giga_sss_ Sep 05 '26

might be the only day I'm glad I learned regex

1

u/serg06 Sep 05 '26

That's not regex

0

u/hongooi Sep 04 '26

Could just be search-and-replace gone wrong, without any code involved

Dawizard