//正则

第一种方法

            Regex regex = new Regex(@"\d{0,}\.\d{0,}\,\d{0,}\.\d{0,}");//经纬度表达式
            string result = regex.Match(text).Value;//查找出字符中经纬度的值
            第二种 输出找到的结果集
            string reg = @"\d{0,}\.\d{0,}\,\d{0,}\.\d{0,}";
             var aaa = GetPathPoint(html, reg);

 /// <summary>
        /// 获取正则表达式匹配结果集
        /// </summary>
        /// <param name="value">字符串</param>
        /// <param name="regx">正则表达式</param>
        /// <returns></returns>
        public static string[] GetPathPoint(string value, string regx)
        {
            if (string.IsNullOrWhiteSpace(value))
            {
                return null;
            }
            bool isMatch = System.Text.RegularExpressions.Regex.IsMatch(value, regx);
            if (!isMatch)
            {
                return null;
            }
            System.Text.RegularExpressions.MatchCollection matchCol = System.Text.RegularExpressions.Regex.Matches(value, regx);
            string [] result = new string[matchCol.Count];
            if (matchCol.Count > 0)
            {
                for (int i = 0; i < matchCol.Count; i++)
                {
                    result[i] = matchCol[i].Value;
                }
            }
            return result;
        }
            第三种 输出找到的结果集
            MatchCollection mc = Regex.Matches(html, reg, RegexOptions.IgnoreCase);
            string [] resultaa = new string[mc.Count];
            if (mc.Count > 0)
            {
                for (int i = 0; i < mc.Count; i++)
                {
                    resultaa[i] = mc[i].Value;
                }
            }

C# 正则表达式输出查询结果的更多相关文章

  1. 转 oracle 正则表达式和查询最大文件号 SQL

    ###sample 1 https://www.cnblogs.com/lxl57610/p/8227599.html Oracle使用正则表达式离不开这4个函数: 1.regexp_like 2.r ...

  2. 用正则表达式输出rdf文档的三元组格式数据

    占个位置 1.输出所有尖括号里的内容 package com.jena; import java.io.BufferedReader; import java.io.FileReader; impor ...

  3. 最简单的ASP.Net连接查询Oracle,输出查询数据到表格中

    VS2012中新建Windows窗体应用程序.Oracle中建测试数据表Test.(此处需要环境已配好情况下进行操作) 用到的数据表 向Windows窗体应用程序,设计界面托一个按钮和一个数据表格视图 ...

  4. java反射与注解结合使用(根据传入对象输出查询sql)

    我们在项目开发中有很多地方使用到了注解,关于注解的定义与创建小伙伴可以参考我的文章<java注解>.有任何问题的小伙伴们可以在评论区指出哦,欢迎各位大佬指出问题. 今天我要说的是使用注解与 ...

  5. 在非SQL客户端使用命令行方式定期连接SQL Server 服务器并模拟用户查询操作,同时输出信息内容

    一个很长的标题,实现的功能就是尽量使用非人力的方式模拟人去做一件事情,为了便于记录,将他们输出成文件方便查阅. 图形界面方式,使用微软自己的ConnMaker.exe,或者Microsoft 数据连接 ...

  6. Thinkphp中的volist标签(查询数据集(select方法)的结果输出)用法简介

    参考网址:http://camnpr.com/archives/1515.html 通常volist标签多用于查询数据集(select方法)的结果输出,通常模型的select方法返回的结果是一个二维数 ...

  7. ElasticSearch入门 第九篇:实现正则表达式查询的思路

    这是ElasticSearch 2.4 版本系列的第九篇: ElasticSearch入门 第一篇:Windows下安装ElasticSearch ElasticSearch入门 第二篇:集群配置 E ...

  8. Linux 命令——grep | 正则表达式

    感觉讲的很详细,瞬间懂了grep,正则. from: here 简介 grep (global search regular expression(RE) and print out the line ...

  9. Shell编程基础教程5--文本过滤、正则表达式、相关命令

    5.文本过滤.正则表达式.相关命令    5.1.正则表达式(什么是正则表达式?正则表达式怎么进行匹配?常用命令)        简介:            一种用来描述文本模式的特殊语法      ...

随机推荐

  1. select监听多个client -- linux函数

    使用select函数能够以非堵塞的方式和多个socket通信.程序仅仅是演示select函数的使用,功能很easy,即使某个连接关闭以后也不会改动当前连接数.连接数达到最大值后会终止程序. 1. 程序 ...

  2. 2014 ACM-ICPC Beijing Invitational Programming Contest

    点击打开链接 Happy Reversal Time Limit: 1000ms Memory Limit: 65536KB 64-bit integer IO format: %lld      J ...

  3. appium(6)-parts of appium api

    parts of appium api Lock Lock the screen.//锁屏. // java driver.lockScreen(3); // objective c [driver ...

  4. Codeforces 724C Ray Tracing 扩展欧几里得

    吐槽:在比赛的时候,压根就没想到这题还可以对称: 题解:http://blog.csdn.net/danliwoo/article/details/52761839 比较详细: #include< ...

  5. SQL:内连接、左外连接、右外连接、全连接、交叉连接区别

    有两个表A和表B.表A结构如下: Aid:int:标识种子,主键,自增ID Aname:varchar 数据情况,即用select * from A出来的记录情况如下图1所示: 图1:A表数据表B结构 ...

  6. 对xml文件的sax解析(增删改查)之二

    先上代码: package com.saxparsetest; //the filename of this file is :saxparse.java import javax.xml.parse ...

  7. php数组合并

    php的数合并函数: array_merge($arr1, $arr2, ..., $arr{$n}); 如果数组的键名有重复,后面的会覆盖前面的. 如果键名是数字索引,则会重新排列索引,往后累加. ...

  8. yii中调取字段名称时label与labelEx的区别

    $form = $this->beginWidget('CActiveForm',array('id' => 'userRegisterForm')); echo $form->la ...

  9. java运行Linux命令

    <%@ page language="java" import="java.util.*,java.io.*" pageEncoding="UT ...

  10. codeforces 702A A. Maximum Increase(水题)

    题目链接: A. Maximum Increase time limit per test 1 second memory limit per test 256 megabytes input sta ...