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 . Link to comment https://forums.phpfreaks.com/topic/51502-regex-completion-problem/ 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> Link to comment https://forums.phpfreaks.com/topic/51502-regex-completion-problem/#findComment-253739 Share on other sites More sharing options...
sachavdk Posted May 15, 2007 Author Share Posted May 15, 2007 Yes it seems to work Thanks! Link to comment https://forums.phpfreaks.com/topic/51502-regex-completion-problem/#findComment-253744 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.