Skip to content
Advertisement

preg_match string from meta name

I want to preg_match number “20,956” from $url1 and number “2,894,865” from $url2

$url1:

JavaScript

$url2:

JavaScript

Tried this to work for both of urls, it works for only $url1 but not in $url2

JavaScript

Any Idea to make it work for both $url1&2?

Advertisement

Answer

You can use

JavaScript

See the regex demo. Details:

  • d – a digit
  • [,d]* – zero or more commas/digits
  • (?=s*visits) – a positive lookahead that requires zero or more whitespaces and then visits string immediately to the right of the current location.

See a PHP demo:

JavaScript

Output:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement