C # regex output query results

            // Regular

 

            the first method 

            Regex regex = new Regex (@ ".. \ D {0,} \ \ d {0,} \, \ d {0,} \ \ d {0,}"); // Coordinates expression
            string result = regex.Match (text) .Value; // Find the value of the character in the longitude and latitude
            The second set of output results found
            string reg = @"\d{0,}\.\d{0,}\,\d{0,}\.\d{0,}";
             var aaa = GetPathPoint (html, reg);

 

 

 /// <summary>

 

        /// get regular expression matching the result set
        /// </summary>
        /// <param name = "value"> character string </ param>
        /// <param name = "regx"> regular expression </ 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;
        }

 

 

 

            A third set of output results found
            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;
                }
            }

Guess you like

Origin www.cnblogs.com/dullbaby/p/11027757.html