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)

254 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 [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo "You live" Sep 03 '26

So is that search result the OP's website?

2

u/cat_sphere Sep 04 '26

This is the official Chinese state registry of clinical trials. I just stumbled across this when I was doing some research and thought it was hilarious. It's basically the equivalent of the american CDC 'Center for disease control' accidentally renaming themselves the 'justify for disease control' because they were updating their CSS or something.

1

u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo "You live" Sep 04 '26

I was thinking you were possibly Chinese.

6

u/Germanface Sep 03 '26

The search result is the title of the webpage, which was (presumably) mangled by the string substitution regex

2

u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo "You live" Sep 04 '26 edited Sep 04 '26

Oh, I guess the "search.html" in the title would imply the regex was applied to the search results page. I had been thinking it was applied to the website shown in the results, and it got indexed with that title.

Edit: Nope, I was right the first time. Look at the page title.

1

u/MurkyWar2756 echo "Sub Mod" && :(){ :|:& };: 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"

2

u/MurkyWar2756 echo "Sub Mod" && :(){ :|:& };: Sep 04 '26

I thought that was a name. Now I see! I knew s/ is used to replace, but I still missed the memo the first time 😂

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/MurkyWar2756 echo "Sub Mod" && :(){ :|:& };: Sep 03 '26

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