RegExp selecting strings surrounded by brackets My purpouse is to select every character which is surrounded by { and }, this is easily achievable using this regexp {\w*}.

I've developed an extenstion method for strings:

    public static IEnumerable&lt;string&gt; ObtainTokens(this string originalString)
    {
        Regex expression = new Regex(@"{\w*}");
        foreach (Match element in expression.Matches(originalString))
        {
            //Exclude the brackets from the returned valued
            yield return Regex.Replace(element.Value, @"{*}*", "");
        }
    }


Is there a way to get rid of of Regex.Replace?
Returning the values as IEnumerable is a good choice?
Modify your regexp: {(\w*)} and then replace:

yield return Regex.Replace(element.Value, @"{*}*", "");


with

yield return element.Groups[1].Value;


ps: full code is avaialbe here