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);
    }

  • 相关阅读:
    函数配接器
    函数对象和函数指针
    unary_function 和 binary_function
    堆排序
    Shell排序
    volatile理解
    死锁
    进程间通信
    优化循环的方法-循环展开
    如何学习编译原理
  • 原文地址:https://www.cnblogs.com/aaa6818162/p/1537774.html
Copyright © 2011-2022 走看看