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

用C#代码分别读取<特殊符号>的前面和后面的代码
字符串随便找个 <特殊符号> 隔开,用C#代码分别读取 <特殊符号> 的前面和后面的代码,用代码怎么截取.ASP.NET中   最好找个例子说明,谢谢了,急~~~~`


------解决方案--------------------
可以用正则表达式试试:
try:
string sourceString = @ "记着$结帖! ";
string pattern = @ "(? <front> [^\$]+?)\$(? <back> [\s\S]+) ";
System.Text.RegularExpressions.Match result = Regex.Match(sourceString,pattern,System.Text.RegularExpressions.RegexOptions.IgnoreCase|System.Text.RegularExpressions.RegexOptions.Multiline);

while(result.Success)
{
WL( "正确: " + result.Groups[ "front "].Value);//输出
WL( "正确: " + result.Groups[ "back "].Value);//输出
result = result.NextMatch();
}

-----------------------------------------------
msn:bdbox@hotmail.com
请给我个与您交流的机会