string s = "Gewerbegebiet Waldstraße"; //other possible input "Waldstrasse"
int iFoundStart = s.IndexOf("strasse", StringComparison.CurrentCulture);
if (iFoundStart > -1)
s = s.Remove(iFoundStart, 7);
I'm running CultureInfo 1031 (german).
IndexOf matches 'straße' or 'strasse' with defined 'strasse' and returns 18 as position.
Neither Remove nor Replace got any overload for setting a culture.
If I remove 6 chars using Remove 1 character will be left if input-string is 'strasse' and 'straße' will work. If input-string is 'straße' and I remove 7 chars I get ArgumentOutOfRangeException.
Is there a way to safely remove the found string? Any method which provides the last index of IndexOf? I stepped closer into IndexOf and it's native code under the hood as expected - so no way to do something own...