If i understand you well... you want to replace "
exception for sqlstate value
" with "
int =
" if a line does not start with "
--
".
If you want to return all lines with changed values, try this:
string[] lines = completeText.Split(stringSeparators, StringSplitOptions.None)
.Select(item=>item.Contains("a") && !item.Trim().StartsWith("--") ? item.Replace("a", "int=") : item)
.ToArray();
Complete - tested - example:
string completeText = "a\nb\nc\n--a\ne\nf\na\nh\ni\n--a\nk\nl";
string[] stringSeparators = new string[] { "\n" };
string[] lines = completeText.Split(stringSeparators, StringSplitOptions.None)
.Select(item=>item.Contains("a") && !item.Trim().StartsWith("--") ? item.Replace("a", "int=") : item)
.ToArray();
Returns an array:
int=
b
c
--a
e
f
int=
h
i
--a
k
l
But...
If you want to return lines which meet your criteria, use
Where
+
Select