zoukankan      html  css  js  c++  java
  • 通过正则表达式 读取数据

    Regex reg = new Regex("(? <= <div [^>]*>)((?!品种代码)[^ <])+(?= </div>)", RegexOptions.IgnoreCase);
    foreach(Match m in reg.Matchs(str))
    {
    Console.WriteLine(m.Value);
    }


    string pattern="<tr [^>]*>\s*<td [^>]*>(?<type>[^<]*)</td>\s*<td [^>]*>(?<open>[^<]*)</td>\s*<td [^>]*>(?<high>[^<]*)</td>\s*<td [^>]*>(?<low>[^<]*)</td>\s*<td [^>]*>(?<close>[^<]*)</td>\s*<td [^>]*>(?<nowprice>[^<]*)</td>\s*<td [^>]*>(?<balance>[^<]*)</td>\s*<td [^>]*>(?<trade>[^<]*)</td>\s*<td [^>]*>(?<count>[^<]*)</td>\s*<td [^>]*><font [^>]*>(?<addcount>[^<]*)</font></td>\s*</tr>";
    Regex reg
    =new Regex(pattern);
    foreach(Match m in reg.Matches(str))
    {
    Console.WriteLine(m.Group[
    "type"].Value);
    Console.WriteLine(m.Group[
    "open"].Value);
    Console.WriteLine(m.Group[
    "high"].Value);
    Console.WriteLine(m.Group[
    "low"].Value);
    Console.WriteLine(m.Group[
    "close"].Value);
    Console.WriteLine(m.Group[
    "nowprice"].Value);
    Console.WriteLine(m.Group[
    "balance"].Value);
    Console.WriteLine(m.Group[
    "trade"].Value);
    Console.WriteLine(m.Group[
    "count"].Value);
    Console.WriteLine(m.Group[
    "addcount"].Value);
    }

  • 相关阅读:
    umask
    mysql 错误总结 和FROM_UNIXTIME用法
    php 读取和下载execl
    Yii 2 load() 和 save()
    iframe 模拟ajax文件上传and formdata ajax 文件上传
    angular.js简单入门。
    mysql 慢日志
    mysql 基本操作 alter
    shell cut 用法
    微信支付与支付宝支付
  • 原文地址:https://www.cnblogs.com/aaa6818162/p/1537774.html
Copyright © 2011-2022 走看看