Reputation: 318
i have this text
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.
58.0.3029 Copyright 2011 Google Inc.
I want is to find everything but
58.0.3029
I use this to find the pattern
\d+(\.\d+\.\d+)
So I have to find all but, the closest I could make was this
[\D+]+([\.\D+][\.\D+])
but it excludes other numbers 5.8 and 2011 too which I don't want to happen
Can you help me to find the right regex for that?
I use http://www.regexpal.com/ to test
I'm using a tool that's been developed with C#
Upvotes: 4
Views: 51
Reputation: 18888
If you want to capture everything but the version number, you can use the following:
([\s\S]*)\b\d+(?:\.\d+){2,}\s*([\s\S]*)
Upvotes: 0
Reputation: 43169
Use anchors (in multiline mode):
^\d[\d.]+
# match the start of the line
# require one digit
# followed by digit(s) and dot(s)
And replace the found match with ''
. See a demo on regex101.com.
Upvotes: 1
Reputation: 4981
To get everything but the version number:
([\s\S]*)\b(\d+\.\d+\.\d+)\b([\s\S]*)
Replace with: $1$3
Output:
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.
Copyright 2011 Google Inc.
Upvotes: 0