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

Edited by murfy
Link to comment
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.