how to remove char (") from the begin and the end of a string ?
如何从字符串的开头和结尾删除char(“)?
ex: "1234"567" ==> 1234"567
例如:“1234”567“==> 1234”567
thank's in advance
提前致谢
1 个解决方案
#1
26
myString = myString.Trim('"');
http://msdn.microsoft.com/en-us/library/d4tt83f9.aspx
http://msdn.microsoft.com/en-us/library/d4tt83f9.aspx
Note that this will remove any amount of quotes at the beginning or the end of the string. If you only want to remove at most one from each end, see Anthony Pegram's answer. Or do it with regex:
请注意,这将删除字符串开头或结尾的任何数量的引号。如果您只想从每一端删除最多一个,请参阅Anthony Pegram的答案。或者使用正则表达式:
myString = Regex.Replace(myString, "^\"|\"$", "");
#1
26
myString = myString.Trim('"');
http://msdn.microsoft.com/en-us/library/d4tt83f9.aspx
http://msdn.microsoft.com/en-us/library/d4tt83f9.aspx
Note that this will remove any amount of quotes at the beginning or the end of the string. If you only want to remove at most one from each end, see Anthony Pegram's answer. Or do it with regex:
请注意,这将删除字符串开头或结尾的任何数量的引号。如果您只想从每一端删除最多一个,请参阅Anthony Pegram的答案。或者使用正则表达式:
myString = Regex.Replace(myString, "^\"|\"$", "");