Search code examples
phppreg-match

php preg_match find number from varriable


I am trying to find laptop's CPU GHZ.

The string is:

Processor: Intel Core i5 5200U 2.2GHz

But the Intel Core i5 5200U can be different string. But I need to find only GHz. I can't do it because Intel Core i5 5200U is changing on every laptop.


Solution

  • Use such regex

    /Processor: .+ ([^\s]+)GHz/
    

    Demo and explanation