如何在两个特定符号之间获取字符串

Bis*_*Roy -1 c# string parsing decoding

我有一个像这样的字符串:***T1***2DAR***R1***.我想在三个不同的字符串中得到这三个(T1,2DAR,R1)值.如何在VS 2015中从单个字符串中的***之类的特定符号之间解码此字符串?

Fab*_*NET 5

使用String类的Split方法:

var values = "***T1***2DAR***R1***".Split(new string[] { "***" }, StringSplitOptions.RemoveEmptyEntries);
Run Code Online (Sandbox Code Playgroud)

编辑:

这将返回一个字符串数组,您可以使用索引器访问每个值:

string s1 = values[0]; // Will give you "T1"
string s2 = values[1]; // Will give you "2DAR"
string s3 = values[2]; // Will give you "R1"
Run Code Online (Sandbox Code Playgroud)