This was a little bit of a struggle just because I never had a need for it.
I wanted to get standard output from the result of grep only on a match of a string. I wanted to get the standard output from a grep match of 5 digits in a string. Here is how you can do it.
echo '12345asdf' | grep -oE '[0-9]{5}'
The result is ‘12345’.
Simple enough but took me about 20 mins to figure it out.