正學正則表示式,剛好需要用到,麻煩大家幫我看看該怎麼截取字符串 有固定格式的字符串:A/B/C,(A、B、C是int或者doublel類型),例如"2299/1/1.00""1027/2/2.00"需要提取第二個"/"開始後的數字"2299/1/1.00" 提取 1.00"1027/2/2.00" 提取 2.00非常感謝大家了! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 (?<=(\d+(\.\d+)?\/){2})\d+(\.\d+)? 謝謝不過我現在隻知道 Regex.IsMatch來匹配,還不會用它來提取我先找找 IsMatch不能提取,用Match或Matchs Regex reg=new Regex(@"(?<=(?:\d+(?:\.\d+)/){2})\d+(\.\d+)");string result=string.Empty;foreach(Match m in reg.Matches("你的字符串")){ result+=m.Value+"\r\n";} 改成:Regex reg=new Regex(@"(?<=(?:\d+(?:\.\d+)?/){2})\d+(?:\.\d+)?"); System.Text.RegularExpressions.Regex r=new System.Text.RegularExpressions.Regex("(?<=(\\d+(\\.\\d+)?\\/){2})\\d+(\\.\\d+)?");System.Text.RegularExpressions.Match m=r.Match("1027/2/2.00");string strResult=m.value; .ashx 文件如何创建Session, 求助:SQL Server查询 C#Form设计的问题(最大化) [请问]如何向局域网内其他的SQL SERVER服务器进行数据读写? 中文问题 请问怎么抓这个 Session 内的值 我希望认识C#的朋友,请留下QQ: 如何兼容不同版本EXCEL.DLL? 那里可以下载基于Exchange的messenger C#能编像'传奇'这样的游戏吗? 高分征求C#在pocket pc上实现类似RichTextBox功能的TextBox -----------------事务 SqlHelper 中错误------!!!
(?<=(\d+(\.\d+)?\/){2})\d+(\.\d+)?
不過我現在隻知道 Regex.IsMatch來匹配,還不會用它來提取
我先找找
用Match或Matchs
Regex reg=new Regex(@"(?<=(?:\d+(?:\.\d+)/){2})\d+(\.\d+)");
string result=string.Empty;
foreach(Match m in reg.Matches("你的字符串"))
{
result+=m.Value+"\r\n";
}
Regex reg=new Regex(@"(?<=(?:\d+(?:\.\d+)?/){2})\d+(?:\.\d+)?");
System.Text.RegularExpressions.Regex r=new System.Text.RegularExpressions.Regex("(?<=(\\d+(\\.\\d+)?\\/){2})\\d+(\\.\\d+)?");
System.Text.RegularExpressions.Match m=r.Match("1027/2/2.00");string strResult=m.value;