I’m looking for String extension methods for TrimStart() and TrimEnd() that accept a string parameter.
I could build one myself but I’m always interested in seeing how other people do things.
How can this be done?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To trim all occurrences of the (exactly matching) string, you can use something like the following:
TrimStart
TrimEnd
To trim any of the characters in trimChars from the start/end of target (e.g.
"foobar'@"@';".TrimEnd(";@'")will return"foobar") you can use the following:TrimStart
TrimEnd