language: C# (mono-2.8)
date: 668 days 4 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System;
using System.Text.RegularExpressions;
 
public class Test
{
        public static void Main()
        {
                String sample = "STUFF   STUFF       **X**     **Y**  STUFF STUFF\r\n"
                              + "J6      INT-00113G  227.905    5.994  180  SOIC8    \r\n"
                              + "J3      INT-00113G  227.905 -203.244  180  SOIC8     \r\n"
                              + "U13     EXCLUDES    -42.210  181.294  180  QFP128    \r\n"
                              + "U3      IC-00276G     5.135  198.644  90   BGA48     \r\n"
                              + "U12     IC-00270G  -123.610 -201.594  0    SOP8      \r\n"
                              + "J1      INT-00112G  269.665  179.894  180  SOIC16    \r\n"
                              + "J2      INT-00112G  269.665  198.144  180  SOIC16    ";
 
                Match xyRegex = Regex.Match(sample, @"(?<x>-?\d+\.\d+)\s+(?<y>-?\d+\.\d+)");
                while (xyRegex.Success)
                {
                        Double xValue = Convert.ToDouble(xyRegex.Groups["x"].Value);
                        Double yValue = Convert.ToDouble(xyRegex.Groups["y"].Value);
 
                        Console.WriteLine("X: {0:0.000}, Y: {1:0.000}", xValue, yValue);
 
                        xyRegex = xyRegex.NextMatch();
                }
        }
}