Jump to content

Recommended Posts

Hi All,

 

I'm new to regex and need some help. I'm trying to parse through a web page to find all the strings below that are separated by new lines:

 

    <h3 class="listing-price">
        
            
                $21,555
            

            
        

        
    </h3>

 

$pattern = 'XXX';
preg_match_all($pattern, $content, $output);

 

Thanks!

What do you want, the dollar amount?

 

The 's' modifier will treat the string as one long string / ignores new lines (if my terminology is correct).

 

$pattern = '~class="listing-price">(.*)</h3>~isU';

 

May give you what you are after, not really sure as you did not specify your expected output..

What do you want, the dollar amount?

 

The 's' modifier will treat the string as one long string / ignores new lines (if my terminology is correct).

 

$pattern = '~class="listing-price">(.*)</h3>~isU';

 

May give you what you are after, not really sure as you did not specify your expected output..

 

Sorry about that...Yes, I'm trying to get the dollar amount without the '$' symbol. So in my example I'm trying get '21,555'. Your pattern works but it includes the '$' with a space in front of it. Thanks!

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.