假设我有字符串:
[(3749.0, 77.19), (3699.0, 86.11), (3648.0, 90.87), (3623.0, 81.35), (3608.0, 88.06), (3601.0, >97.73), (3576.0, 79.31), (3558.0, 84.12), (3551.0, 94.65), (3525.0, 82.88), (3511.0, 87.48),
(3500.0, 97.57), (3450.0, 91.18)]
我怎样才能获得前几组 4 位数字的输出:
3749.0
3699.0
3648.0
3623.0
etc.
非常感谢您的任何反馈。
答案1
答案2
- Ctrl+H
- 找什么:
(?:\[|\G).*?\((\d{4}\.\d)(?:, \d+\.\d+\)\])?
- 替换为:
$1\n
或$1\r\n
取决于平台 - 打钩 环绕
- 选择 正则表达式
- 打钩
. matches newline
- Replace all
解释:
(?:\[|\G) # non capture group, opening square bracket OR restat from last match position
.*? # 0 or more any character, not greedy
\( # opening parenthesis
( # start group 1
\d{4} # 4 digits
\. # a dot
\d # a digit
) # end group 1
(?: # non capture group
, \d+\.\d+ # a comma, a space, 1 or more digits, a dot, 1 or more digits)
\) # closing parenthesis
\] # closing square bracket
)? # end group, optional
截图(之前):