roguetrip wrote: ↑April 13th, 2019, 8:56 pm
Thanks for the reply.
I had actually got it working later on but using alot of optional
? Quantifiers
Using
Substitute="^.*?-?([A-Z]?\d{3,}[A-Z]?[A-Z]?).*?$":"\1" allowed me to work well with AMD cpu and Intel model numbers.
With your simplified
(?U)^.*-(.*\d{3,}.*) .*$ regex looks to work well anything with a
-, It looks like it would not (to me atleast) work with a CPU like
AMD(R) Ryzen 1800X Eight-Core Processor as it has no leading
- to start before the capture.
Testing in ATOM with your regex atleast shows me it won't pickup the AMD string.
Edit: Sure enough your regex does rely on the
- when creating a String Measure containing...
AMD(R) Ryzen 1800X Eight-Core Processor and doesn't work
Not to be boasting but my regex does work around it and outputs
1800X
Trying to figure how to mod yours now... It looks better than mine
Well, I worked with the samples you and jsmorley have provided, and they did have a leading
-.
Other than that, you did more or less the same as I did, because
.*? actually makes the
.* lazy (similar, but slighly different to the
(?U) flag that I used), basically matching as few characters as possible. In practice, the
? does not mean optional in this case, but has the role of "inverting" the previous greedy
*.
That being said, if I think about it, for the following hypothetical cases, your regex will return
567 and
1800XY for the last 2 rows (use the multiline flag when testing online, that will simulate different rows to be taken as different strings). This happens as
567 is the first match because of the lazy
.*? on the 3rd row and, of course, more than 2 letters follow the digits on the 4th row.
Code: Select all
Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz
AMD FX(tm)-8320 Eight-Core Processor
AMD(R) Ryzen567 1800X Eight-Core Processor
AMD(R) Ryzen 1800XYZ 567Eight-Core Processor
On the other hand, something like
^.*[- ](\d{3,}[A-Z]*) .*$ will match things correctly. You know, since you thought modding my regex would look better...