Reputation: 21
This is the string I have. Script:
Select * from tablename()
/*
go
*/
My code looks like this
private string RemoveBetween(string editScript, char begin, char end)
{
Regex regex = new Regex(string.Format("///.*?///", begin, end));
return regex.Replace(editScript, string.Empty);
}
editscript = RemoveBetween(editscript, '/', '/');
AM unable to remove the text between /*----*/
.
Upvotes: 1
Views: 516
Reputation: 5402
private string RemoveBetween(String editScript, String begin, String end)
{
return Regex.Replace(editScript,
String.Format("{0}.*?{1}", begin, end),
String.Empty,
RegexOptions.Singleline)
}
usage:
editscript = RemoveBetween(editscript, "/", "/");
I've changed your signature to use String
, because you probably might want to call it like so (to remove SQL comment blocks):
editscript = RemoveBetween(editscript, "/\*", "\*/");
Upvotes: 1