I have in class around 100 Regex
calls, every call cover different type of data in text protocol, but i have many files and based on analytics regex
took 88% of execution of my code.
Many this type of code:
{
Match m_said = Regex.Match(line, @"(.*) said,", RegexOptions.IgnoreCase);
if (m_said.Success)
{
string playername = ma.Groups[1].Value;
// some action
return true;
}
}
{
Match ma = Regex.Match(line, @"(.*) is connected", RegexOptions.IgnoreCase);
if (ma.Success)
{
string playername = ma.Groups[1].Value;
// some action
return true;
}
}
{
Match ma = Regex.Match(line, @"(.*): brings in for (.*)", RegexOptions.IgnoreCase);
if (ma.Success)
{
string playername = ma.Groups[1].Value;
long amount = Detect_Value(ma.Groups[2].Value, line);
// some action
return true;
}
}
Is any way to replace Regex
with some other faster solution?