Andrus,
Place the string in a StringReader, and read line by line from the
string. For each line, look for two dashes. If you find it, take
everything to the left, and then add the line (without the comments) to a
StringBuilder which is being constructed without the comments.
I am curious, why are you removing the comments?
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Andrus" <ko********@hot.eewrote in message
news:uS**************@TK2MSFTNGP02.phx.gbl...
>I have SQL strings which contain comments starting with -- and continuing
to end of line like
string mystring=@"SELECT data, -- ending comment
-- line comment
FROM mytable
";
How to remove comment from those strings ?
I need to delete charactes starting from -- and ending with line end in
strings.
In whole line comments emty line may remain or may removed, no difference.
Andrus.