gpt4 book ai didi

regex - 查找除版本号以外的所有内容

转载 作者:行者123 更新时间:2023-12-01 04:48:49 25 4
gpt4 key购买 nike

我有这个文字

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# 开发的工具

最佳答案

使用 anchor (在多行模式下):

^\d[\d.]+
# match the start of the line
# require one digit
# followed by digit(s) and dot(s)

并将找到的匹配替换为 '' .见 a demo on regex101.com .

关于regex - 查找除版本号以外的所有内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43855109/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com