我正在尝试将 Regex 用于我正在做的工作项目。我有一组看起来像这样的数字:
23 14 62 -121 98 -0.0 -0.1 0.0 -0.2 165 60.00 .... ...
24 13 64 -118 101 -0.0 -0.1 0.0 -0.2 165 60.00 .... ...
19 10 65 -124 93 -0.0 -0.1 0.0 -0.2 165 60.00 .... ...
19 11 62 -130 93 -0.0 -0.1 0.0 -0.2 165 60.00 .... ...
16 2 65 -127 83 -0.0 -0.1 0.0 -0.2 165 60.00 .... ...
18 1 68 -127 86 -0.0 -0.1 0.0 -0.2 165 60.00 .... ...
29 -1 64 -129 92 -0.0 -0.1 0.0 -0.2 165 60.00 .... ...
22 2 63 -131 87 -0.0 -0.1 0.0 -0.2 165 60.00 .... ...
16 13 62 -130 91 -0.0 -0.1 0.0 -0.2 165 60.00 .... ...
15 6 66 -131 87 -0.0 -0.1 0.0 -0.2 165 60.00 .... ...
16 2 62 -137 80 -0.0 -0.1 0.0 -0.2 165 60.00 .... ...
16 -5 63 -133 74 -0.0 -0.1 0.0 -0.2 165 60.00 .... ...
24 -1 60 -135 83 -0.0 -0.1 0.0 -0.2 165 60.00 .... ...
15 11 59 -137 86 -0.0 -0.1 0.0 -0.2 165 60.00 .... ...
11 8 64 -131 83 -0.0 -0.1 0.0 -0.2 165 60.00 .... ...
19 10 64 -130 92 -0.0 -0.1 0.0 -0.2 165 60.00 .... ...
20 11 65 -136 96 -0.0 -0.1 0.0 -0.2 165 60.00 .... ...
20 8 59 -136 87 -0.0 -0.1 0.0 -0.2 165 60.00 .... ...
18 13 59 -135 90 -0.0 -0.1 0.0 -0.2 165 60.00 .... ...
18 10 60 -138 88 -0.0 -0.1 0.0 -0.2 165 60.00 .... ...
23 6 60 -133 88 -0.0 -0.1 0.0 -0.2 165 60.00 .... ...
20 10 57 -127 87 -0.0 -0.1 0.0 -0.2 165 60.00 .... ...
23 4 61 -127 88 -0.0 -0.1 0.0 -0.2 165 60.00 .... ...
14 -3 63 -131 75 -0.0 -0.1 0.0 -0.2 165 60.00 .... ...
16 -5 62 -129 73 -0.0 -0.1 0.0 -0.2 165 60.00 .... ...
25 -6 62 -127 80 -0.0 -0.1 0.0 -0.2 165 60.00 .... ...
21 2 60 -129 83 -0.0 -0.1 0.0 -0.2 165 60.00 .... ...
14 3 65 -133 81 -0.0 -0.1 0.0 -0.2 165 60.00 .... ...
14 8 64 -132 86 -0.0 -0.1 0.0 -0.2 165 60.00 .... ...
19 11 59 -131 89 -0.0 -0.1 0.0 -0.2 165 60.00 .... ...
28 5 59 -129 93 -0.0 -0.1 0.0 -0.2 165 60.00 .... ...
29 -3 56 -130 82 -0.0 -0.1 0.0 -0.2 165 60.00 .... ...
24 0 58 -128 82 -0.0 -0.1 0.0 -0.2 165 60.00 .... ...
28 12 65 -128 104 -0.0 -0.1 0.0 -0.2 165 60.00 .... ...
25 4 65 -123 94 -0.0 -0.1 0.0 -0.2 165 60.00 .... ...
17 -1 61 -126 77 -0.0 -0.1 0.0 -0.2 165 60.00 .... ...
18 2 62 -130 82 -0.0 -0.1 0.0 -0.2 165 60.00 .... ...
我想只用一个或两个正则表达式语句来获得每行中的第 10 个数字(165)。该数字偶尔会从 165 更改,因此我无法对其进行硬编码。到目前为止,我有:
([+-]{0,1}[0-9]{1,5})
([+-]{0,1}[0-9]{1,5})
([+-]{0,1}[0-9]{1,5})
([+-]{0,1}[0-9]{1,5})
([+-]{0,1}[0-9]{1,5})
([+-]{0,1}[0-9]{1,}[.]{0,1}[0-9]{0,5})|([+-]{0,1}[.]{1,1}(?=[0-9])[0-9]{0,5}))
([+-]{0,1}[0-9]{1,}[.]{0,1}[0-9]{0,5})|([+-]{0,1}[.]{1,1}(?=[0-9])[0-9]{0,5}))
([+-]{0,1}[0-9]{1,}[.]{0,1}[0-9]{0,5})|([+-]{0,1}[.]{1,1}(?=[0-9])[0-9]{0,5}))
([+-]{0,1}[0-9]{1,}[.]{0,1}[0-9]{0,5})|([+-]{0,1}[.]{1,1}(?=[0-9])[0-9]{0,5}))
([+-]{0,1}[0-9]{1,5})
这显然不是 1 或 2 步,而是 10 加,它给了我 9 分,我不想要。有没有办法在只有 1 或 2 条语句中得到这个?