void DoParseExpressions (string str)
{
int startIndex = 0, index = 0;
Regex codeDirective = new Regex ("(<%(?!@)(?<code>(.|\\s)*?)%>)|(<[\\w:\\.]+.*?runat=[\"']?server[\"']?.*?/>)",
RegexOptions.Multiline | RegexOptions.Compiled | RegexOptions.CultureInvariant);
Match match;
int strLen = str.Length;
while (index > -1 && startIndex < strLen) {
match = codeDirective.Match (str, index);
if (match.Success) {
string value = match.Value;
index = match.Index;
if (index > startIndex)
TextParsed (null, str.Substring (startIndex, index - startIndex));
DoParse (value);
index += value.Length;
startIndex = index;
} else
break;
if (index < strLen)
index = str.IndexOf ('<', index);
else
break;
}
if (startIndex < strLen)
TextParsed (null, str.Substring (startIndex));
}