M
Morgan Cheng
In my case, I have to remove any line containing "0.000000" from input
string.
In below case, it takes about 100 ms for 2k size input string.
Regex.Replace(inputString, ".*0\\.000000.*\n", "");
I want to optimize it, so i make a static member instance instead of
using static func of Regex;
static Regex filter= new Regex(".*0\\.000000.*\n",
RegexOptions.Compiled);
And use the static instance to replace the string.
filter.Replace(inputString, "");
Now, it takes about 200 ms. The platform is .net 1.1.
I don't understand why the non-static member function is slower thant
static one. The static function has to compile the regular expression
each time, right?
Is there any better solution to remove substring of specific pattern?
Perhaps I have to write my code to do it.
Thanks,
-Morgan
string.
In below case, it takes about 100 ms for 2k size input string.
Regex.Replace(inputString, ".*0\\.000000.*\n", "");
I want to optimize it, so i make a static member instance instead of
using static func of Regex;
static Regex filter= new Regex(".*0\\.000000.*\n",
RegexOptions.Compiled);
And use the static instance to replace the string.
filter.Replace(inputString, "");
Now, it takes about 200 ms. The platform is .net 1.1.
I don't understand why the non-static member function is slower thant
static one. The static function has to compile the regular expression
each time, right?
Is there any better solution to remove substring of specific pattern?
Perhaps I have to write my code to do it.
Thanks,
-Morgan