Solved

php with preg match

Posted on 2011-09-08
3
299 Views
Last Modified: 2012-06-27
how can I match this site when the last digits always change
site.com/?d=YS98IIR06

Open in new window

0
Comment
Question by:XK8ER
  • 2
3 Comments
 
LVL 82

Expert Comment

by:hielo
ID: 36506105
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
 
LVL 35

Accepted Solution

by:
Terry Woods earned 500 total points
ID: 36506414
Or if the entire value of the variable can change:
preg_match('#site.com/\?d=[^&]+#', $var);
0
 
LVL 35

Expert Comment

by:Terry Woods
ID: 36506420
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

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now