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. Quote 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. Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.