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! 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"; } ?> 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? 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 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 =( 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 ? 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 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 Link to comment https://forums.phpfreaks.com/topic/148306-preg_match-help/#findComment-778894 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.