Search notes:

System.Text.RegularExpressions.Regex - Replace()

Overloads

public static string Replace (string input, string pattern, string replacement);
public static string Replace (string input, string pattern, string replacement, System.Text.RegularExpressions.RegexOptions options, TimeSpan matchTimeout);

public static string Replace (string input, string pattern, System.Text.RegularExpressions.MatchEvaluator evaluator);
public static string Replace (string input, string pattern, System.Text.RegularExpressions.MatchEvaluator evaluator, System.Text.RegularExpressions.RegexOptions options);
public static string Replace (string input, string pattern, System.Text.RegularExpressions.MatchEvaluator evaluator, System.Text.RegularExpressions.RegexOptions options, TimeSpan matchTimeout);

public        string Replace (string input, System.Text.RegularExpressions.MatchEvaluator evaluator, int count, int startat);

public        string Replace (string input, string replacement, int count);

PowerShell example

The following PowerShell example replaces the text from the first character to and including the first line that starts with BEGIN:
$txt = @'
one two three
four BEGIN five
six seven eight nine
BEGIN
abc defghi jklm no
pq BEGIN rstu
vwx yz
BEGIN
hello world
BEGIN
end.
'@

[regex] $pat = '(?ms).*?^BEGIN\n?'

$repl = $pat.Replace($txt, '', 1)
">$repl<"
Note that this example enables multiline and singlemode mode with (?ms) so that ^ matches the beginning of a line within the input string and . matches new lines as well.

See also

System.Text.RegularExpressions.Regex

Index