I\'m looking for String extension methods for TrimStart()
and TrimEnd()
that accept a string parameter.
I could build one myself but I\'m alw
I'm assuming you mean that, for example, given the string "HelloWorld" and calling the function to 'trim' the start with "Hello" you'd be left with "World". I'd argue that this is really a substring operation as you're removing a portion of the string of known length, rather than a trim operation which removes an unknown length of string.
As such, we created a couple of extension methods named SubstringAfter
and SubstringBefore
. It would be nice to have them in the framework, but they aren't so you need to implement them yourselves. Don't forget to have a StringComparison
parameter, and to use Ordinal
as the default if you make it optional.