还有人会正则表达式?看看什么意思

来源:百度知道 编辑:UC知道 时间:2024/05/23 11:38:40
[\S\s]*?
[\S\s][^<>]*?
什么意思?
public string[] CutStr(string sStr, string Patrn)
{
Regex regex1 = new Regex(Patrn, RegexOptions.Compiled);
MatchCollection collection1 = regex1.Matches(sStr);
if (collection1.Count != 0)
{
string[] textArray1 = new string[collection1.Count];
for (int num1 = 0; num1 < collection1.Count; num1++)
{
textArray1[num1] = collection1[num1].Groups[1].Value;
}
return textArray1;
}
return new string[] {""};
}
这个什么意思???
请再补充一下

[\S\s]*? //0到多个空字符或非空字符
[\S\s][^<>]*? //第一个字符是空字符或非空字符第二个以后是0到多个非<或>的字符

public string[] CutStr(string sStr, string Patrn)
{
Regex regex1 = new Regex(Patrn, RegexOptions.Compiled);
获取所有匹配正则表式patrn的组的集合
MatchCollection collection1 = regex1.Matches(sStr);
if (collection1.Count != 0)
{
string[] textArray1 = new string[collection1.Count];
for (int num1 = 0; num1 < collection1.Count; num1++)
{
//获取每个组的集合中的组的一个值
textArray1[num1] = collection1[num1].Groups[1].Value;
}
return textArray1;
}
return new string[] {""};
}

[\S\s]

这个在JAVA中,直接写成.就可以了吧...