print only matched string instead lines in grep

frnd,
Is there any way to print only the string that matched the pattern instead printing the whole line?

thanks in advance.

With GNU grep:

grep -o STRING file ...

With sed:

sed -n '/STRING/ s/.*\(STRING\).*/\1/p'

hi cfajohnson..

very thanks.
but my pattern is a regex.
in that case?

Replace STRING with your regex.