Algorithm for expanding a character set?
<p>Are there any ready-made functions for expanding a C# regex-style character set?</p>

<p>For example, <code>expand("a-z1")</code> would return a string containing all the characters a to z, followed by the number 1. </p>

<hr>

<p>Here's what I've got so far:
    public static string ExpandCharacterSet(string set)
    {
        var sb = new StringBuilder();
        int start = 0;</p>

<pre><code>    while (start &lt; set.Length - 1)
    {
        int dash = set.IndexOf('-', start + 1);

        if (dash &lt;= 0 || dash &gt;= set.Length - 1)
            break;

        sb.Append(set.Substring(start, dash - start - 1));

        char a = set[dash - 1];
        char z = set[dash + 1];

        for (var i = a; i &lt;= z; ++i)
            sb.Append(i);

        start = dash + 2;
    }

    sb.Append(set.Substring(start));
    return sb.ToString();
}
</code></pre>

<p>Is there anything I'm overlooking?</p>

<p><strong>PS:</strong> Let's ignore negative character sets for now.</p>

<hr>

<p>Thought my example was quite clear... let's try that again. This is what I want:</p>

<pre><code>ExpandCharacterSet("a-fA-F0-9") == "abcdefABCDEF0123456789"
</code></pre>
