Jump to content

Help with regular expressions that include new lines


insomnomaniac

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!

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.