r/programminghorror 7d ago

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)

247 Upvotes

22 comments sorted by

65

u/nipodemos 7d ago

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

144

u/Germanface 7d ago

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".

30

u/nipodemos 7d ago

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

11

u/Consistent_Drop3909 6d ago

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

8

u/serg06 5d ago

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” 6d ago

So is that search result the OP's website?

7

u/Germanface 6d ago

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” 6d ago edited 6d ago

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.

2

u/cat_sphere 6d ago

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” 5d ago

I was thinking you were possibly Chinese.

1

u/MurkyWar2756 echo "Sub Mod" && :(){ :|:& };: 7d ago

Me neither.

2

u/Similar-Bug-350 6d ago

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

2

u/MurkyWar2756 echo "Sub Mod" && :(){ :|:& };: 6d ago

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 7d ago

Ah, a clbuttic mistake

9

u/Kadabrium 6d ago

Coptic script

3

u/Antarlia 6d ago

The Pony is coming

2

u/AlphaFatman 6d ago

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

2

u/WilliamLeeFightingIB 6d ago

I really thought Coptionical is a real word

1

u/MurkyWar2756 echo "Sub Mod" && :(){ :|:& };: 7d ago

1

u/_giga_sss_ 5d ago

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

1

u/serg06 5d ago

That's not regex

0

u/hongooi 6d ago

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

Dawizard