I am having troubles removing backslash from my string. The string is like this "3adsadas34\". I want to remove the backslash at the end, I tried with:
urlContent = realUrl.Remove(realUrl.Length - 1, 1);
But it doesn't want to work. I would like to know if I can use regex, and if I can, maybe someone can provide regex sample for removing '\' from that string, or some other way to remove the backslash is more then welcome. Thanks in advance, Laziale
Try this
urlContent = realUrl.TrimEnd('\\');
Note: You have to escape the backslash.
char ch = '\\';
string s = "\\";
string verbatimString = @"\";
Your Remove
code looks OK. realUrl.Substring(0, realUrl.Length-1)
would do the same. The problem might be somewhere else.
you can use trim end,
realUrl.TrimEnd('\\');
Remember, this will remove all trailing occurences of '\'
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