following on from Griff's solution:
Regex matcher = new Regex("^(RE|4T|4S)", RegexOptions.ExplicitCapture | RegexOptions.Compiled);
rchTxtContent.Lines = (from code_Projects in rchTxtContent.Lines
where !matcher.IsMatch(code_Projects)
select code_Projects).ToArray();
This will just remove the lines that begin with any of the 3 two-character strings.
Additional considerations:
If this is a compile-time fixed pattern, then make the
matcher
a
private static readonly
field of the class (instead of a local variable of the method) and then the construction and compilation (relatively expensive) of the
Regex
will happen only once.
You can add the
RegexOptions.IgnoreCase
to the constructor if you need this to be case insensitive.