我有类似下面的字符串值:
string str1 = "123-456-test";
string str1 = "123 - 456 - test-test";
string str1 = "123-REQ456-test";
string str1 = "123 - REQ456 - test-test";
Run Code Online (Sandbox Code Playgroud)
我需要在第二个破折号后立即从字符串中获取整个内容.
我试过了String.Split('-'),但没办法.我想我需要使用正则表达式,但我找不到正确的正则表达式.请建议.
string str1 = "123-456-test";
int secondIndex = str1.IndexOf('-', str1.IndexOf('-') + 1);
str1 = str1.Substring(secondIndex + 1); // test
Run Code Online (Sandbox Code Playgroud)