Jump to content

Macthing strings over multiple lines


gazsp

Recommended Posts

Hi all,

 

This is my first post and I'm relatively new to regular expressions so please bear with me :-)

 

I've worked out a regular expression that works correctly in my text editor (TextMate) which is

 

    ^(BODY:)((\n?)|(.?))+(-----)

 

What I'm trying to do is match the string 'BODY:', then everything afterwards including newlines, then the string '-----'. The expression matches exactly what I need in my text editor, but when I use it in PHP as

 

    $body_regexp = "/\r(BODY:)((\n?)|(.?))+(-----)/";
    $match = preg_match_all($body_regexp, $file, $matches);

 

the match for the second sub-expression is always empty.

 

Can anybody shed some light on this for me please?

 

Cheers,

Gaz.

Link to comment
https://forums.phpfreaks.com/topic/125437-macthing-strings-over-multiple-lines/
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.