C#-字符串拆分,是否包含指定字符,取值等处理

1.(1)str1.Split(','):按,分割str1

    (2)str1=str.Split(new[] { "1ada" }, StringSplitOptions.None)[1];//按1ada分割str,取分割后集合的第二个值

2.str1.indexOf(str2) :str1包含str2

3.Regex.Match(str1, "(?<=str1).*?(?=str2")").Value;

   Regex.Match(str1, "(?<=str1)[sS]*?(?=str2")").Value;

未整理前

string str="( [ 1486, 427 ][ 流水号: ][ 0.977335 ])( [ 2271, 287 ][ 1/1 ][ 0.994448 ])"

Regex.Match(str1, "(?<=流水号:).*?(?=")").Value;

// 页码
cWSL.NumberOfPages = Regex.Matches(str1, @"(?<=[).*?(?=/)")[0].ToString()+ Regex.Matches(str1, @"(?<=[).*?(?=/)")[0].ToString();

C#截取两个关键字之间的字符串

4.Regex.Matchs(str1, "(?<=str1).*?(?=str2")").Value;

5.C# 截取字符串方法总结

6.字符串中去除指定字符

365个夜晚,我希望做到两天更一篇博客。加油,小白!
原文地址:https://www.cnblogs.com/qq2806933146xiaobai/p/13372241.html