I can count the number of matching links with the preg_match_all()
function like below, which checked if the inner text of the link is equal to the specified keyword.
// text contains two different links, whereby the inner
// text of the first link is capitalized and the second link starts with a small letter.
$string = "<p><a href=\"www.link1.com\" class=\"someClass\" title=\"lorem\">Lorem</a> dolor sit amet, consectetur
adipiscing elit. In iaculis, libero aliquam lacinia feugiat, <a href=\"www.link2.com\" class=\"someClass\" title=\"lorem\">lorem</a>
elit congue risus, sed sagittis turpis tortor eget orci. Integer lacinia quis nisi ac aliquet. Sed et convallis diam.</p>";
// count al matches by upper and lowercase sensitivity
preg_match_all('/<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>lorem<\/a>/siU', $string, $match);
Now my question is how I can make the regex so that it's also works for matches with a capital letter.