I'm using C# and I have a stringbuilder sb
which has some lines containing strings separated by tabs as shown below:
1.14332 534335 4452435435
1.32332 534535 4354535435
1.34432 524335 4353235435
1.44332 534435 4352235435
.
.
.
what I want to do is to search in this string builder for a string, and if this string is found then I want to replace the whole line containing this string with another new string. So for example if the word I want to search for is 1.32332
then this line 1.32332 534535 4354535435
in sb
will be replaced with a new substring for example 1.32332 664535 1154536665
. Any advice please?
ToString()
to get the string, do the replacement and you're done.StringBuilder
, could you perhaps refactor your code to do this replace before you've appended the values?StringBuilder
in the first place is to not have to fiddle with entire strings. If you can do this replace before the values are appended, it will probably be more performant than converting to a string and doing a replace on that.