我有如下的字符串值:
string str1 = "123-456-test";
string str1 = "123 - 456 - test-test";
string str1 = "123-REQ456-test";
string str1 = "123 - REQ456 - test-test";
我需要在第二个破折号之后立即从字符串中获取整个内容。
I tried String.Split('-')
,但没有成功。我认为我需要使用正则表达式,但我无法找到正确的正则表达式。请建议。
对于像这样的字符串方法来说这甚至很容易IndexOf and Substring.
string str1 = "123-456-test";
int secondIndex = str1.IndexOf('-', str1.IndexOf('-') + 1);
str1 = str1.Substring(secondIndex + 1); // test
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)