guitarist809 Posted February 14, 2007 Share Posted February 14, 2007 Hello, I have the following code: $block_pattern = '#<!-- BEGIN (.*?) -->(.*?)<!-- END (.*?) -->#'; $str = " <!-- BEGIN TYPE1 -->Text inbetwee adfsdfdfadn comments ' ] [ { } stuff<!-- END TYPEe1 --> <!-- BEGIN SWITCH LOGIN -->[asdf]<!-- END SWITCH LOGIN -->"; preg_match_all($block_pattern, $str, $matches); echo ("<pre>"); print_r($matches); echo "</pre>"; I'm trying to match something like this <!-- BEGIN name -->TEXT HERE<!-- END name --> It works if its just one line, if it's like <!-- BEGIN name -->TEXT a d f s HERE<!-- END name --> it doesn't match. How can I match it if there's more than one line (and some tabs)? Quote Link to comment Share on other sites More sharing options...
effigy Posted February 14, 2007 Share Posted February 14, 2007 Use the s modifier. Quote Link to comment Share on other sites More sharing options...
guitarist809 Posted February 14, 2007 Author Share Posted February 14, 2007 Thx That seems to be what I'm missing. One more question (sorry, I'm still really new to regex), where do I put the \s thing? Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted February 14, 2007 Share Posted February 14, 2007 add s at the end of the regex pattern: $block_pattern = '#<!-- BEGIN (.*?) -->(.*?)<!-- END (.*?) -->#s'; Quote Link to comment Share on other sites More sharing options...
guitarist809 Posted February 14, 2007 Author Share Posted February 14, 2007 add s at the end of the regex pattern: $block_pattern = '#<!-- BEGIN (.*?) -->(.*?)<!-- END (.*?) -->#s'; aww. it's so simple! but THANK YOU!! IT WORKED!! w00t!!!! How do i set this topic to solved? Quote Link to comment Share on other sites More sharing options...
effigy Posted February 15, 2007 Share Posted February 15, 2007 How do i set this topic to solved? There's a button in the bottom right corner, after all of the posts. You can also search for "topic solved" to find it. Quote Link to comment 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.