How many times you have to bullet proof your application against some bad or junk data ? Sometimes we might not have anticipated some scenario until quite a while. And this can quite possible if your application relies on some other program ( data from web service, some sort of incoming XML or something like that )
Well LINQ is your friend !
Just a heads up :
Going forward I shall try to maintain all string manipulation related posts ALSO under ‘string-manipulation‘ tag, just if that helps you drill down the content better. Cheers ! 😉
// code snippet string s = "kf khg ddkfhg dfgh ldfg ss=\"XXXX\" dfgdfkgjhdkfgh ss=\";XXX YYY Z\" kjdhkfhg difhgkdhgfk dhkgfh dkfghkdhgf ss=\"XX Y ZZZ\" fghfgh\""; var v = s.Split('"').Where((ss, n) => n % 2 == 0); string stripped = string.Join("", v); // end
kf khg ddkfhg dfgh ldfg ss= dfgdfkgjhdkfgh ss= kjdhkfhg difhgkdhgfk dhkgfh dkfghkdhgf ss= fghfgh