Reputation: 11
I am trying to match regex with the following html response after an curl operation, if it displays
Results: Displaying 1 of 1 entries
then i have the following code set-up
$pos = strpos($response, 'Results: Displaying 1 of 1 entries');
and I use if
($pos !== false)` in order to do stuff
however I need to also match conditions where I need to fine-tune search arguments if it will return an set of results (more then 1)
so something like Results: Displaying 1 of X entries
where x is greater then 1
what regex expression may be used with strpos to match this condition
Upvotes: 1
Views: 50
Reputation:
You will have to use preg_match(): https://www.php.net/preg_match
int preg_match ( string $pattern , string $subject [, array &$matches [, int $flags = 0 [, int $offset = 0 ]]] )
Your regex might be something like:
Results: Displaying 1 of ([0-9]+) entries
To check if the number is greater than 1, you'll have to compare the first captured group, which can be found in the array &$matches[1] (the third parameter, see php documentation).
Upvotes: 1