我有这个文字
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.
58.0.3029 Copyright 2011 Google Inc.
我想要的是找到所有东西,但
58.0.3029
我用它来找到模式
\d+(\.\d+\.\d+)
所以我必须找到所有,但我能做的最接近的是
[\D+]+([\.\D+][\.\D+])
但它也排除了我不想发生的其他数字5.8和2011
你能帮我找到合适的正则表达式吗?
我使用http://www.regexpal.com/来测试
我使用的是使用C#开发的工具
答案 0 :(得分:1)
使用锚点(在多线模式下):
^\d[\d.]+
# match the start of the line
# require one digit
# followed by digit(s) and dot(s)
并将找到的匹配项替换为''
。请参阅a demo on regex101.com。
答案 1 :(得分:0)
答案 2 :(得分:0)
获取除版本号以外的所有内容:
([\s\S]*)\b(\d+\.\d+\.\d+)\b([\s\S]*)
替换为:$1$3
输出:
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.
Copyright 2011 Google Inc.