私はクラスで約100回Regex
コールを持っていますが、すべてのコールはテキストプロトコルのさまざまな種類のデータをカバーしますが、私は多くのファイルを持ち、分析に基づいていますregex
は私のコードの88%Regexのより速い置き換え
多くのこの種のコード:
{
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;
}
}
は、他のいくつかの高速化ソリューションでRegex
を置き換えるためにどのような方法か?ループでテストされている正規表現については
私はあなたが使用している正規表現の種類に依存すると思う...いくつかのサンプルを提供! –