我有以下几行:
Data 5 in:out:40 Files
我希望匹配所有字符串直到第3个空格,所以,在这种情况下,我想要回来
Data 5 in:out:40
答案 0 :(得分:0)
怎么样:
^(\S+\s+\S+\s+\S+)
让我们打破这个:
^ # start from string beginning
( # match everything inside (begin)
\S+ # match all non-whitespace(s)
\s+ # whitespace(s)
\d+ # match all non-whitespace(s)
\s+ # whitespace(s)
\S+ # match all non-whitespace(s)
) # match everything inside (end)