Tell me why my regular expression does not see the second definition of the text, but if you move a string, it determines. Is it possible to make an expression so that it defines the second text without a line break?

Regular Expression: /(.+)</th>/

<th style="width:500px"> Number of replies </th><th> % of responses </th>

    1 answer 1

    You need to use a more greedy option:

     <?php preg_match_all("|<th.*>([\s\S]*)<\/th>|U", "<th>example: </th><th align=left>this блабла is a test</th>", $out, PREG_PATTERN_ORDER); print_r($out); ?> 

    result:

     Array ( [0] => Array ( [0] => <th>example: </th> [1] => <th align=left>this блабла is a test</th> ) [1] => Array ( [0] => example: [1] => this блабла is a test ) ) 
    • Thank you very much! I will delve into) - Ilja Zakonov