Link to home
Start Free TrialLog in
Avatar of XK8ER
XK8ERFlag for United States of America

asked on

php with preg match

how can I match this site when the last digits always change
site.com/?d=YS98IIR06

Open in new window

Avatar of hielo
hielo
Flag of Wallis and Futuna image

you mean the last "06" only?
$var='site.com/?d=YS98IIR06';

If yes and you want to limit to two digits only
preg_match('#site.com/[?]=YS98IIR\d\d#', $var)

If you want to limit to at least one digit:
preg_match('#site.com/[?]=YS98IIR\d+#', $var)


zero or more digits:
preg_match('#site.com/[?]=YS98IIR\d*#', $var)
ASKER CERTIFIED SOLUTION
Avatar of Terry Woods
Terry Woods
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Note that we can provide all sorts of different patterns that will match - what's also important though is what you want to NOT match. You might like to describe that too.