I have the following piece of code which should match the provided string to $contents. $contents variable has a web page contents stored through file_get_contents() function:
if (preg_match('~<p style="margin-top: 40px; " class="head">GENE:<b>(.*?)</b>~iU', $contents, $match)){
$found_match = $match[1];
}
The original string on the said webpage looks like this:
<p style="margin-top: 40px; " class="head">GENE:<b>TSPAN6</b>
I would like to match and store the string ‘TSPAN6’ found on the web page through (.*?) into $match[1]. However, the matching does not seem to work. Any ideas?
Unfortunately, your suggestion did not work.
After some hours of looking through the html code I have realized that the regex simply had a blank space right after the colon. As such, the code snippet now looks like this: