I always stutter and use filler words when speaking to a lot of people at a time. So I need something to remove all my filler words.

So here is the challenge.

Your program should take input as a string. You can assume that all characters in the string are ASCII printables with character codes between 32 and 126 inclusive, and contains at least one character which is not a space or a period ..


  1. Split the input into sentences by periods followed by spaces. In other words, . .
  2. Remove any um, uh, like or you know from the string (case-insensitive). (Not substrings, but space-seperated "words" or "phrases", for example sum and ayou knowb are left unchanged).
  3. Replace any continuous string of two or more spaces with one space.
  4. Titlecase the first word of every sentence. That is, make the first character (if it is a letter in [A-Za-z]) uppercase and the other letters lowercase.
  5. Remove all spaces before a comma, and any spaces before the first non-space character.

The steps are only done once, not until the string stops changing.

However, filler words in quoted strings should not be removed, as this is not using the words, this is mentioning them. A string is quoted iff it is between an odd-numbered " and an even-numbered one (the first one is number 1, the next 2, and so on).

Test cases:

Hi, it's me here. -> Hi, it's me here.
Like this sucks. -> This sucks.
Today, I will be using, um uh uh um Linux. -> Today, I will be using, Linux.
JS floats have like, 64 bits. -> Js floats have, 64 bits.
"Um" is an overused word. -> "Um" is an overused word.
"Um" has hex codes, uh 55, and you know, 6d. -> "Um" has hex codes, 55, and, 6d.
You know I love code golf. -> I love code golf.
Say "like" and "uh" less. -> Say "like" and "uh" less.
Um "uh" like "you know" -> "uh" "you know"
Ah yes,     Spaces! -> Ah yes, Spaces!
Um here are two sentences. Uh um this is the last one. -> Here are two sentences. This is the last one.
Uh 1. Uh digits again. -> 1. Digits again.
Uh +1. Um    plus one. -> +1. Plus one.
uM aLtErNaTiNg CaPs -> Alternating CaPs
   , get it right! -> , get it right!
Who even likes it? -> Who even likes it? 
1.5 is a fine number. -> 1.5 is a fine number.
cOmPoUnD-wOrD. -> Compound-word.
cOmPoUnD_wOrD. -> Compound_word.
_uNdErScOrE. -> _underscore.
1A is hex. -> 1a is hex.
Yes, you you know know what I mean. -> Yes, you know what I mean.
"Fruit flies like bananas. As said." just like "Time flies like an arrow. As said." -> "Fruit flies like bananas. As said." just like "Time flies an arrow. As said."
Um. You know. Yes. -> . . Yes.

This is , so fewest bytes wins!

  • 3
    \$\begingroup\$ Please define "word". \$\endgroup\$
    – Adám
    Commented Apr 2 at 21:00
  • 1
    \$\begingroup\$ Suggested test case: _uNdErScOrE \$\endgroup\$
    – Adám
    Commented Apr 3 at 4:35
  • 3
    \$\begingroup\$ What is expected for you you know know what i mean (should i remove you know the second time?), "Fruit flies like bananas. As said." just like "Time flies like an arrow. As said." (if i split by . first, then how to count even or odd quotes?) \$\endgroup\$
    – tsh
    Commented Apr 3 at 5:17
  • 3
    \$\begingroup\$ And what about some sentences which only contain stop words? Um. You know. Yes. \$\endgroup\$
    – tsh
    Commented Apr 3 at 5:24
  • 2
    \$\begingroup\$ You have address many (but not all) spec issues by adding test cases. Thanks! However, please update the actual spec rather than just relying on the tests. \$\endgroup\$
    – Adám
    Commented Apr 3 at 17:07

5 Answers 5


QuadR i≡, 80 78 bytes

−2 thanks to inspiration from Neil's Retina answer.

^ +| (?= |,)|\b(um|uh|like|you know)\b
(^|\. )([a-z])(\w*)


Try it online!

Will be explained once the spec is fully settled.

This is equivalent to the Dyalog APL function '"[^"]*"' '^ +| (?= |,)|\b(um|uh|like|you know)\b' '(^|\. )([a-z])(\w*)'⎕R'&' '' '\1\u2\l3'⍠1⍣≡


Swift 5.9, 246 bytes

import Foundation
let f={($0+"").replacing(#/(^| +)?(u[mh]|like|you know)( +|,)/#.ignoresCase()){$0.output.3+"\t"}.replacing(#/ +,/#,with:",").replacing(#/\t[a-zA-Z]+/#){$0.output.capitalized}.replacing(#/^ |\t/#,with:"").replacing(#/ +/#,with:" ")}

To get 246 bytes, replace the three occurrences of \t with a literal tab character.

  • \$\begingroup\$ StackExchange replaces tabs with 4 spaces so the second code block is wrong I think \$\endgroup\$ Commented Apr 3 at 2:42
  • \$\begingroup\$ @noodleman You're right, I didn't realize that. \$\endgroup\$ Commented Apr 3 at 11:14

Retina 0.8.2, 111 bytes

i`\b(um|uh|like|you know)\b(?=(([^"]*"){2})*[^"]*$)

^ +| +( |,)
T`L`l`(^|\. )[^ .]+
T`l`L`(^|\. )[^\w .]*\w

Try it online! Link includes test cases. Explanation:

i`\b(um|uh|like|you know)\b(?=(([^"]*"){2})*[^"]*$)

Delete filler words that aren't quoted.

^ +| +( |,)

Delete leading spaces and spaces before spaces or commas.

T`L`l`(^|\. )[^ .]+
T`l`L`(^|\. )[^\w .]*\w

Title case the first word of each sentence.


Python 3, 273 bytes

import re
s = input().split(". ")
g = re.sub
def f(x):
    x=g(r'\s*,',',',g(r'\s+',' ',g(r'(?<!\")\b(um|uh|like|you know)\b(?!\")', '', x.lstrip(), flags=re.IGNORECASE)))
    return x[0].upper()+x[1:]+"."
s = [f(x) for x in s]
s[-1] = s[-1][:-1]
print(" ".join(s))

Not sure if I'm printing properly, or if it's necessary

  • \$\begingroup\$ Welcome to codegolf! You can save a lot of bytes by remocing unnecessary whitespace, like the one around equal signs. \$\endgroup\$
    – movatica
    Commented Apr 4 at 22:19
  • \$\begingroup\$ Thank you! I didn't see that bit there \$\endgroup\$ Commented Apr 5 at 6:22

Perl 5 -pF\", 103 bytes

map++$i%2&&s/\b(um|uh|like|you know)\b//gi,@F;$_=join'"',@F;s/^ *| +?(?=,| )//g;s/(^|\. )\K\S+/\u\L$&/g

Try it online!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.