Everybody loves golfing code. Code is written in English (eh...). Therefore, everybody loves golfing English!
Your task is to write a program or function that takes a string as input, and then returns or prints the golfed version. There will be no newlines or tabs in the input.
This is how you golf a string. The order matters!
remove spaces directly before and after punctuation:
"Hey there", he said ; he ' s a cat. -> "Hey there",he said;he's a cat.
The following count as punctuation:.,?!"':;()
replace
he/she/it is
withhe's/she's/it's
:It is unfortunate that she is not coming ever. -> It's unfortunate that she's not coming ever.
Also,He is here
should not becomeHe's here
; it should remain unchanged.words that start with capital letters in a sentence can be moved against the preceding word (omitting the space):
The farmer told Fred that he should leave. -> The farmer toldFred that he should leave.
trailing and leading whitespace should be removed:
[ ]It's raining.[ ]-> It's raining.
Ignore the brackets (annoying auto-formatting).Remove repeated punctuation that is the same:
""Here''s the cake",, said Fred..! -> "Here's the cake",saidFred.!
If we were to golf the first paragraph of this challenge, the output would be:
Everybody loves golfing code.Code is written inEnglish(eh.).Therefore,everybody loves golfingEnglish!
This is code golf––or rather English golf––so shortest code in bytes wins!