sachavdk Posted May 15, 2007 Share Posted May 15, 2007 I've got a regex pattern here, partitionally working. it should match {{m}{module_name}{parameter1|parameter2|...}} What I already have is "#^\{\{[a-z]*\}\{[a-z0-9_/]*\}(.*)\}$#i", which matches {{m}{module_name}(.*)} correctly. Now I can't get the parameter part working. It should leave {parameterlist} optional and the pipe-seperated parameters should be stored in the backreference (using preg_match). Any help is appreciated . Quote Link to comment Share on other sites More sharing options...
effigy Posted May 15, 2007 Share Posted May 15, 2007 Something like this? <pre> <?php $tests = array( '{{m}{module_name}{parameter1|parameter2}}', '{{m}{module_name}}', ); foreach ($tests as $test) { echo "<b>$test</b><br>"; preg_match('# ^ \{ \{[a-z]*\} \{[a-z0-9_/]*\} (?:\{(.*?)\})? \} \z #ix', $test, $matches); print_r($matches); } ?> </pre> Quote Link to comment Share on other sites More sharing options...
sachavdk Posted May 15, 2007 Author Share Posted May 15, 2007 Yes it seems to work Thanks! 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.