Reputation: 3410
Here's my input text:
Intel Core i3-4170 3.7GHz
I'm trying to replace 3.7GHz
with XXX
Here's my pattern:
/\s(?=[^\s]+(.*?GHz)$)/
but this matches: i3-4170 3.7GHz
if I add the global flag I get what I need in the 2nd group, but I'm not sure if that's reliable.
https://regex101.com/r/ARa1tG/1
Upvotes: 0
Views: 52
Reputation: 887
My answer:
\b\d+(?:\.\d+)?ghz\b
\b // word boundary
\d+ // 1 or more digits
(?: // optional group (not captured)
\.\d+ // a dot, then 1 or more digits
)? // end of group
ghz // literal
\b // word boundary
Upvotes: 0