Dmitry Makovetskiyd
Dmitry Makovetskiyd

Reputation: 7053

Regex in PHP doesn't work

       $subject= "Citation flow <img src='/static/images/icons/help.png'>
                                </span>
                            </p>
                            <p style='font-size: 150%;'><b>11</b></p>";
           $pattern="/Citation flow[.]+<b>([0-9]+)<\/b>/i";

          preg_match_all($pattern, $subject,$matches,PREG_PATTERN_ORDER);

          print_r($matches);

I want to capture the number 11 inisde the bold tags.. but my regex expression doesnt work.. why?

UPDATE:

I came up with this.. but I am not 100% it is the best solution:

$pattern="/Citation flow[\s\S]*<b>([0-9]+)<\/b>/i";

Upvotes: 0

Views: 140

Answers (2)

BugFinder
BugFinder

Reputation: 17858

Do you not want

$pattern="/Citation flow[.]+<b>([0-9]+)<\/b>/si"; 

Upvotes: 0

Joey
Joey

Reputation: 354546

Well, it cannot match as Citation flow has a space after it, not an arbitrary number of dots. You probably meant

(?si)Citation flow.+<b>(\d+)</b>

Upvotes: 3

Related Questions