Skip to main content

Regex to separate capital letter words from title case words? [Resolved]

I have a string formatted like this:

Meaningless Garbage I Don't Want INFO I'M LOOKING FOR

The meaningless garbage and the info I'm looking for are of variable length, however the info I'm looking for will always be in uppercase, and the other stuff will always be in title case.

Is there any way at all to separate it with a regular expression? I'm not very good at regex, so I don't know what's possible.


Question Credit: Shervan
Question Reference
Asked October 10, 2018
Posted Under: Unix Linux
14 views
2 Answers

echo "Meaningless Garbage I Don't Want INFO I'M LOOKING FOR" | grep -Eo -e '\b[A-Z'\'']{2,}\b'
INFO
I'M
LOOKING
FOR

credit: Goro
Answered October 10, 2018

Assuming the title case will ALWAYS end in a lower case letter, try

sed 's/^.*[a-z] //' file
INFO I'M LOOKING FOR

credit: RudiC
Answered October 10, 2018
Your Answer
D:\Adnan\Candoerz\CandoProject\vQA