Page 1 of 1

regex help

Posted: Tue Dec 30, 2008 2:31 am
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:!)

Re: regex help

Posted: Tue Dec 30, 2008 5:04 am
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+)#

Re: regex help

Posted: Tue Dec 30, 2008 5:56 am
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!

Re: regex help

Posted: Tue Dec 30, 2008 6:43 am
by requinix
Look harder at what I posted. All you have to do is wrap it in quotes.