Reputation: 1063
I am trying to delete all words that start with capital letters but below is just catching "Al" from the first word:
echo "Always baby Yeah" | sed -r 's/^([AEIOU].)//g'
How do I capture just all the words starting with capital letters?
Upvotes: 0
Views: 1332
Reputation: 77105
This regex should work \b[A-Z](\w*)\b
[jaypal:~/Temp] echo "Always baby Yeah" | sed -r 's/\b[A-Z](\w*)\b//g'
baby
Upvotes: 0
Reputation: 96266
You only remove the first two characters and only if they are at the start of the string.
Use: sed -r 's/\b[A-Z]\w*//g'
or 's/\b[A-Z]\w*\s*//g'
if you want to remove the whitespace too.
Upvotes: 2