Get value of substring from a file

Hi,

I have a file with a long string, in the format:

name1=value,name2=value2.....namen=valuen

I want to query the file and extract 'value2' ONLY. name2=value2 can exist anywhere within the file.
Can anyone help me please wth a suitable BASH command?

Many thanks,

Matt

sed 's/.*name2=\(value2\).*/\1/g' infile

Thanks for that,

I didn't make it clear, the value is not fixed and can vary in length, however, 'name3' IS known and fixed

Np,

sed 's/.*name2=\([^=,]*\),.*/\1/g'

Off the cuff awk script:

/name2=/ {
        recs = split($0, a, ",")
        for ( i=1; i<=recs; i++)
        {
                if( a ~ /name2=/   )
                {
                  print  substr(a,7)
                }
        }
}