gazsp Posted September 23, 2008 Share Posted September 23, 2008 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 More sharing options...
effigy Posted September 23, 2008 Share Posted September 23, 2008 /^(BODY:)(.+?)(-----)/ms /m enables multi-line mode and /s allows . to match new lines. Link to comment https://forums.phpfreaks.com/topic/125437-macthing-strings-over-multiple-lines/#findComment-648642 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.