i would like to match recursively, all text that ends with : or / or ; or , and remove all these characters, along with any spaces left behind, in the end of the text.
Example:
some text : ; , /
should become:
some text
What i have tried, just removes the first occurrence of any of these special characters found, how one can do this recursively, so as to delete all characters found that match? regex i use:
find: [ ,;:/]*
replace with nothing
[ ,;:/]*$ should be what you need. This is the same as your current regex except with the $ on the end. The $ tells it that the match must happen at the end of the string.
You can use C#'s TrimEnd() like so
string line = "some text : ; , / "
char[] charsToTrim = {',', ':', ';', ' ', '/'};
string trimmedLine = line.TrimEnd(charsToTrim);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With