Calculating the 'binary gap' of a number
I think using Regex will be too much for this little task. A simple split by 1s should suffice.

public static int ComputeLargestBinaryGap2(int value)
{
    return Convert
            // convert to binary
            .ToString(value, 2)
            // remove leading and trailing 0s, as per requirement
            .Trim('0')
            // split the string by 1s
            .Split(new [] { '1' })
            // find the length of longest segment
            .Max(x =&gt; x.Length);
}


We can also solve the problem from a mathematical approach, with logical operators and bit-shiftings :

public static int ComputeLargestBinaryGap3(int value)
{
    // casting it to uint while keeping the same binary value, like reinterpret_cast&lt;unsigned int&gt;
    //var unsigned = BitConverter.ToUInt32(BitConverter.GetBytes(value), 0);
    var unsigned = unchecked((uint)value);
    // flag used to ignore counting trailing 0's
    var pastTrailing0 = false;

    int max = 0, count = 0;
    while(unsigned &gt; 0)
    {
        if ((unsigned &amp; 1) == 1)
        {
            if (count &gt; max)
                max = count;

            count = 0;
            pastTrailing0 = true;
        }
        else if (pastTrailing0)
        {
            count++;
        }

        unsigned = unsigned &gt;&gt; 1;
    }

    return max;
}




EDIT: After this answer was posted, OP updated on his definition of "best", which leans toward readability. I'll add my comments on his code here :


There is no benefit in declaring the variable, regexp , for the regular express, without giving a meaningful name to it, other than stating the obvious. It should be renamed to binaryGap.
valueAsBinary is a quite misleading name. One would think it the value stored in the binary format, which is pretty much how every number is stored... However, it stores the binary string of value. Therefore, it should be renamed to binaryString, or valueAsBinaryString.
The Match class already have a Length property that could be used instead of the long way match.Value.Length. This property is cached, so we are not re-measuring the length of the string, as you can see here.


And, here is the final result :

public static int ComputeLargestBinaryGap(int value)
{
    var binaryGap = new Regex("(?&lt;=1)(0+)(?=1)");
    var binaryString = Convert.ToString(value, 2);
    return 
        binaryGap.Matches(binaryString)
            .Cast&lt;Match&gt;()
            .Select(m =&gt; m.Length)
            .DefaultIfEmpty(0)
            .Max();
}