没有合适的资源?快使用搜索试试~ 我知道了~
使用正则表达式取出数据
需积分: 9 2 下载量 82 浏览量
2014-09-05
16:03:55
上传
评论
收藏 5KB TXT 举报
温馨提示
试读
4页
取数据有多种方式,正则相对比较准确,此处还介绍了连接数据库的方法。
资源推荐
资源详情
资源评论
private DataTable extract(string sourcecode,string startCity,string endCity)
{
DataTable da = createCollDataTable();
string flightcode = "[\u4e00-\u9fff]+含.+?</td>";//航班号
Regex flightregex = new Regex(flightcode);
MatchCollection flight = flightregex.Matches(sourcecode);
string Seatcode = "<span >\r\n.+[A-Z0-9]/";//舱位
Regex seatco = new Regex(Seatcode);
MatchCollection seat = seatco.Matches(sourcecode);
string seatcode1 = "[A-Z0-9]+/";
Regex seatreg = new Regex(seatcode1);
string rebate = @"[0-9]+\.[0-9]{1}\r";//折扣率
Regex reba=new Regex(rebate);
MatchCollection rebatecode = reba.Matches(sourcecode);
string effectivedata="<td align=\"center\" style=\"width:50px;\">\r\n\\s+[0-9]{2}-[0-9]{2}-[0-9]{2}<br />\r\n\\s+[0-9]{2}-[0-9]{2}-[0-9]{2}";//有效日期,出票日期
Regex effectiveda = new Regex(effectivedata);
MatchCollection effective = effectiveda.Matches(sourcecode);
string data = "[0-9]{2}-[0-9]{2}-[0-9]{2}";
Regex efdata = new Regex(data);
string iss = "id=\"gvList_ctl[0-9]{2}_btnCan\"";
Regex issef = new Regex(iss);
MatchCollection isse = issef.Matches(sourcecode);
Regex clude = new Regex("[\u4e00-\u9fff]+含:");
Regex include = new Regex("[0-9A-Z]{6}");
int count=seat.Count;
for (int i = 0; i < count; i++)
{
tol++;
MatchCollection flight1 = include.Matches(flight[i].Value);
MatchCollection seat1 = seatreg.Matches(seat[i].Value);
{
DataTable da = createCollDataTable();
string flightcode = "[\u4e00-\u9fff]+含.+?</td>";//航班号
Regex flightregex = new Regex(flightcode);
MatchCollection flight = flightregex.Matches(sourcecode);
string Seatcode = "<span >\r\n.+[A-Z0-9]/";//舱位
Regex seatco = new Regex(Seatcode);
MatchCollection seat = seatco.Matches(sourcecode);
string seatcode1 = "[A-Z0-9]+/";
Regex seatreg = new Regex(seatcode1);
string rebate = @"[0-9]+\.[0-9]{1}\r";//折扣率
Regex reba=new Regex(rebate);
MatchCollection rebatecode = reba.Matches(sourcecode);
string effectivedata="<td align=\"center\" style=\"width:50px;\">\r\n\\s+[0-9]{2}-[0-9]{2}-[0-9]{2}<br />\r\n\\s+[0-9]{2}-[0-9]{2}-[0-9]{2}";//有效日期,出票日期
Regex effectiveda = new Regex(effectivedata);
MatchCollection effective = effectiveda.Matches(sourcecode);
string data = "[0-9]{2}-[0-9]{2}-[0-9]{2}";
Regex efdata = new Regex(data);
string iss = "id=\"gvList_ctl[0-9]{2}_btnCan\"";
Regex issef = new Regex(iss);
MatchCollection isse = issef.Matches(sourcecode);
Regex clude = new Regex("[\u4e00-\u9fff]+含:");
Regex include = new Regex("[0-9A-Z]{6}");
int count=seat.Count;
for (int i = 0; i < count; i++)
{
tol++;
MatchCollection flight1 = include.Matches(flight[i].Value);
MatchCollection seat1 = seatreg.Matches(seat[i].Value);
资源评论
yongbing112
- 粉丝: 0
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功