SoFunction
Updated on 2025-03-09

PHP obtains regular expressions for hyperlink text content (five methods)

I won’t say much nonsense, I will share with you five methods, explaining the regular expressions of the hyperlink text content through the code of PHP.

//Method 1 

preg_match_all("/<(a|a)[s]{0,1}[w=":()]*>[ ]*(check user)[ ]*</(a|a)>/i",$string,$matches);

//Method 2

preg_match_all("/<a[dd]*>check user</a>/i",$string,$matches);
print_r($matches[0]);

//Method 3

preg_match_all("/<a[^>]*>[^<]*</a>/i",$string,$matches);
print_r($matches[0]);

//Method 4

preg_match_all("/<a.+?>check user</a>/is",$str,$arr);

//Method 5

preg_match_all("/<a.+?>check user</a>/is",$str,$arr);

The above is the regular expression (five methods) for obtaining hyperlink text content from PHP that the editor introduced to you. I hope you like it.