Jump to content

regular expression


murfy

Recommended Posts

Hello I  need help with this reg. exp. for preg_match_all

 

@(?<=style=\"display: inline\">)\d{1,3}(?=\.?<)@

Subject:

<span style="display: inline">113</span><span
class="qazL">.</span><span style="display: inline">111</span

Returns:

array (
0 =>
array (
0 => '113',
1 => 30,
),
)

Should return values 113 and 111 in the array. How to correct this?

 

Tested here:

http://www.functions-online.com/preg_match.html

Link to comment
https://forums.phpfreaks.com/topic/284795-regular-expression/
Share on other sites

 

preg_match_all("#<span style=\"display: inline\"[^>]*>(\d*)#is", $subject, $matches, PREG_OFFSET_CAPTURE);
echo "<pre>" . print_r($matches, 1) . "</pre>";

 

Output:

 

Array
(
    [0] => Array
        (
            [0] => Array
                (
                    [0] => 113
                    [1] => 0
                )
            [1] => Array
                (
                    [0] => 111
                    [1] => 68
                )
        )

    [1] => Array
        (
            [0] => Array
                (
                    [0] => 113
                    [1] => 30
                )
            [1] => Array
                (
                    [0] => 111
                    [1] => 98
                )
        )
)
Link to comment
https://forums.phpfreaks.com/topic/284795-regular-expression/#findComment-1462458
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.