Preg_match_all question

Joined
Nov 8, 2017
Messages
35
Reaction score
11
Aloha everyone,

I'm still having trouble wrapping my head around preg_match_all My ADHD brain hasn't seen the pattern yet.

I have a var with web page content. How to I grab all urls with nnnn in them?

Thanks,

Rick
 
You should try to give a better example as there are many possible ways
 
You should try to give a better example as there are many possible ways

Like I said I'm still wrapping my head around preg_match_all but I like the fact I can avoid having to loop

but the links would be like this

Code:
<a href="http://nnnn.vendor.company" target="_blank">
 
I got this function to work. How can I edit it so I only get urls with nnnn in them?

Code:
function getUrls($string) {
 $regex = '/https?\:\/\/[^\" ]+/i';
 preg_match_all($regex, $string, $matches);
 return ($matches[0]);
}

//$urls = getUrls($string);

//print_r($urls);
 
Back
Top