tags:

views:

58

answers:

1

Require regular expression for matching below string

'/test_25-5?page=5'
A: 

preg_match is what you're looking for and Understanding RegEx

pseudo code (I have not tested the code it's an example to help you in the right direction)

$string = '/test_25-5?page=5';

// The "i" after the pattern delimiter indicates a case-insensitive search
if (preg_match("/\/[a-z]+_[\d]+\?[a-z]+=[\d]+$/i", $string)) {
    echo "A match was found.";
} else {
    echo "A match was not found.";
}
Phill Pafford
i think there are some errors in your regex -> `^/[\w\d]+-[\d]+\?[a-z]+=[\d]+$`
Hannes
yes as you can see it's tagged as pseudo code, something to point him in the right direction
Phill Pafford