regex help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mikey119
Forum Newbie
Posts: 2
Joined: Tue Dec 30, 2008 2:25 am

regex help

Post by mikey119 »

I am parsing a list of URLs
the urls where before
http://www.example.com/j_d.php?j_i=1111
now they are
http://www.example.com/j_d/1111/random_text

Before I had this match pattern
if (preg_match_all('/href=["\']j_d\.php\?j_i=(\d+)/', $html, $m)) {

Now I am trying to figure out the new one
if (preg_match_all('/href=["\']j_d\(\d+)\*', $html, $m)) {

but cannot! Help me out please:!)
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: regex help

Post by requinix »

I could help you out by telling you to go post in the Regex forum, or I could tell you to learn regular expressions before trying to use them, but I'll do something else instead:

Code: Select all

#href=["']j_d/(\d+)#
mikey119
Forum Newbie
Posts: 2
Joined: Tue Dec 30, 2008 2:25 am

Re: regex help

Post by mikey119 »

sorry did not realize that there was a regex forum.

still not working :

if (preg_match_all('/href=["\']j_d\(\d+)#\', $html, $m)) {
Warning: preg_match_all() [function.preg-match-all]: No ending delimiter '/'

if (preg_match_all('/href=["\']j_d\\(\d+)#/', $html, $m)) {
Warning: preg_match_all() [function.preg-match-all]: Compilation failed: unmatched parentheses at offset 25

if (preg_match_all('/href=["\']j_d/\(\d+)#/', $html, $m)) {
Warning: preg_match_all() [function.preg-match-all]: Unknown modifier '\'

if (preg_match_all('/href=["\']j_d\(\d+)/#', $html, $m)) {
Unknown modifier '#'

Thanks for all you help.
Wishing you all a good 2009!
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: regex help

Post by requinix »

Look harder at what I posted. All you have to do is wrap it in quotes.
Post Reply