Porl123 Posted March 6, 2009 Share Posted March 6, 2009 I've got a script when it logs into an account using cURL, stores the page in $buf with htmlentities so preg_match can read through the source, but I'm not too good with preg_match so I think this is probably completely wrong. Would somebody be able to show me how I'd fix the below to find characters a-z (any case) and digits 0-9? I think you should be able to see what I'm trying to do here preg_match('%<td><a href="profile.php?u=([a-Z0-9])">([a-Z0-9])</a></td>%', $buf, $matches); If you can help me at all it will be appreciated, thanks! Quote Link to comment https://forums.phpfreaks.com/topic/148306-preg_match-help/ Share on other sites More sharing options...
redarrow Posted March 7, 2009 Share Posted March 7, 2009 example for you mate. <?php $buf='<a href="profile.php?u=ASDfrgt234">ASderfDe1276</a>'; if(preg_match("/^(<a href=)\"(profile\.php)\?(u)\=[a-z0-9\"\>][a-z0-9\<\>]/i",$buf)){ echo "Valid"; }else{ echo "Not Valid"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/148306-preg_match-help/#findComment-778629 Share on other sites More sharing options...
Porl123 Posted March 7, 2009 Author Share Posted March 7, 2009 Sorry I posted the wrong regex <td><a href="profie.php?username=(.*)">(.*)</a></td> Does anyone know how I can get those returns? Quote Link to comment https://forums.phpfreaks.com/topic/148306-preg_match-help/#findComment-778661 Share on other sites More sharing options...
.josh Posted March 7, 2009 Share Posted March 7, 2009 preg_match('~<td><a href="profie.php?username=([^"]*)">(.*?)</a></td>~',$buf, $matches); echo "<pre>"; print_r($matches); // to see the array structure of your returns Quote Link to comment https://forums.phpfreaks.com/topic/148306-preg_match-help/#findComment-778667 Share on other sites More sharing options...
Porl123 Posted March 7, 2009 Author Share Posted March 7, 2009 It's weird though. That should work but it's not returning anything =( Quote Link to comment https://forums.phpfreaks.com/topic/148306-preg_match-help/#findComment-778675 Share on other sites More sharing options...
.josh Posted March 7, 2009 Share Posted March 7, 2009 well I do notice the string you provided for the pattern says profie.php perhaps you meant to have profile.php ? Quote Link to comment https://forums.phpfreaks.com/topic/148306-preg_match-help/#findComment-778684 Share on other sites More sharing options...
Porl123 Posted March 7, 2009 Author Share Posted March 7, 2009 Yeah I saw that before but it's till return nothing =( everything's should be working Quote Link to comment https://forums.phpfreaks.com/topic/148306-preg_match-help/#findComment-778790 Share on other sites More sharing options...
.josh Posted March 7, 2009 Share Posted March 7, 2009 then post an example of the content Quote Link to comment https://forums.phpfreaks.com/topic/148306-preg_match-help/#findComment-778894 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.