您可以使用
((?:\d.)+)
测试字符串
... Dashbuilder before 0.6.0.Beta allows remote ...
匹配更多信息
MATCH 1
1. [23-29] `0.6.0.`
DEMO:https://regex101.com/r/pW8gO5/1
编辑
要提取before 0.6.0.Beta
使用:
(\b\w+\s(?:\d.)+\w+\b)
测试字符串
... Dashbuilder before 0.6.0.Beta allows remote ...
匹配更多信息
MATCH 1
1. [16-33] `before 0.6.0.Beta`
DEMO:https://regex101.com/r/pW8gO5/2
EDIT 2
您可以使用?
搭配可选before
字:
((?:before)?\s(?:\d.)+\w+\b)
测试管柱
... Dashbuilder before 0.6.0.Beta allows remote ...
... Dashbuilder 0.6.0.Beta allows remote ...
匹配更多信息
MATCH 1
1. [16-33] `before 0.6.0.Beta`
MATCH 2
1. [69-80] ` 0.6.0.Beta`
DEMO:https://regex101.com/r/pW8gO5/3
编辑3
更新以匹配版本太。
((?:before)?\s(?:[\d.])+[\w-]+)\b
测试字符串
... Dashbuilder before 0.6.0.Alpha allows remote ...
... Dashbuilder before 0.6.0.Beta allows remote ...
... Dashbuilder before 0.6.0.Beta allows remote ...
... Dashbuilder before 0.6.0 allows remote ...
... Dashbuilder before 0.6.0.SNAPSHOT allows remote ...
... Dashbuilder before 0.6.0.RC allows remote ...
... Dashbuilder before 0.6.0-RELEASE allows remote ...
匹配更多信息
MATCH 1
1. [16-34] `before 0.6.0.Alpha`
MATCH 2
1. [70-87] `before 0.6.0.Beta`
MATCH 3
1. [123-140] `before 0.6.0.Beta`
MATCH 4
1. [176-188] `before 0.6.0`
MATCH 5
1. [224-245] `before 0.6.0.SNAPSHOT`
MATCH 6
1. [281-296] `before 0.6.0.RC`
MATCH 7
1. [332-352] `before 0.6.0-RELEASE`
DEMO:https://regex101.com/r/pW8gO5/4
我能找到最短的版本:'\ d [^ \ S] +' - https:// regex101。com/r/pW8gO5/5 - 编辑:'\ d [^] +'也可以。 – Yaron