php with preg match

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

Open in new window

LVL 1
XK8ERAsked:
Who is Participating?
 
Terry WoodsConnect With a Mentor IT GuruCommented:
Or if the entire value of the variable can change:
preg_match('#site.com/\?d=[^&]+#', $var);
0
 
hieloCommented:
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)
0
 
Terry WoodsIT GuruCommented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.