'Optimization Regex for dxf-File LINE objects only
Consider a String containing a chain with or without stuff in between of elements like
LINE
8
0
62
0
10
86.106
20
-319.701000011
11
61.722
21
-319.701000011
0
I use the following regex to find the coordinates of each LINE:
LINE\n 8\n\d\n 62\n\d\n 10\n(?<X1>-?\d+\.\d+)\n 20\n(?<Y1>-?\d+\.\d+)\n 11\n(?<X2>-?\d+\.\d+)\n 21\n(?<Y2>-?\d+\.\d+)\n 0\n?
I get correctly for every LINE element 4 groups in the example X1 = 86.106, Y1 = -319.701000011, X2 = 61.722, Y2 = -319.701000011
I created it with a tutorial for regex. So is there anything I can learn from improving this attempt?
For example I imagine its very useful, if I could round the group results already to 3 decimal places.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
