Extract a substring using regular expression

Hello:

I'm trying to extracta a matching substring from a string using regular expression. I need to extract the date part of any giving string.

All input string will have date in YYYYMMDD format in them, but it can be anywhere in the string.

Eg.

The_Mummy20080125_New
Lost_20071227_In_time
Last20010915Samurai

All I want is to assign the 8 digit date part to a variable.

I tried
$Date_val = echo "The_Mummy20080125_New" | sed "s/._\([[:digit:]]\{8\}\)$/\1/p"

But it does not work. Someone please help me.

Thanks,
Raja

Try it this way:

sed 's/.*\([[:digit:]]\{8\}\).*/\1/'

Regards

Awesome!!!