C# 截取指定字符串之间的字符串

发布于:2021-10-19 06:48:45

string startstr = "BEGIN PUBLIC KEY-----";
string endstr = "-----END PUBLIC KEY";
int startindex, endindex;
//fileStringReader是要操作的字符串
startindex = fileStringReader.IndexOf(startstr);
string tmpstr = fileStringReader.Substring(startindex + startstr.Length);
endindex = tmpstr.IndexOf(endstr);
string result = tmpstr.Remove(endindex);

相关推荐

最新更新

猜你喜欢