日期:2014-05-18  浏览次数:20782 次

.net中字符串分割
string str = "wearaasdad$$$$dasdasdasd$$$dasdasdad a$$$$dasdgfdsgs$dasd$$$$";
有这样一个字符串,如何根据"$$$$"这个字符串分割str?
就是我要获取wearaasdad,dasdasdasd$$$dasdasdad a,dasdgfdsgs$dasd这三个字符串,求各位大虾帮忙!

------解决方案--------------------
C# code

 string str = @"wearaasdad$$$$dasdasdasd$$$dasdasdad a$$$$dasdgfdsgs$dasd$$$$";
 string[] xstr=str.Split(new string[] { @"$$$$" }, StringSplitOptions.RemoveEmptyEntries);

------解决方案--------------------
额,看错了,没注意是四个$$$$
2楼正解
------解决方案--------------------
C# code
string str = "wearaasdad$$$$dasdasdasd$$$dasdasdad a$$$$dasdgfdsgs$dasd$$$$";
string[] result=Regex.Split(str,@"\$\$\$\$");