php - News content blocks and custom Regular Expression -
i need create little facility create news article editors php software. have created way use custom block , module editors include static or dynamic blocks , modules including in text:
example:
lorem ipsum dolor sit amet, consectetur adipiscing elit. etiam in mollis libero. phasellus sollicitudin ligula pharetra magna egestas mattis. {block name="ads1"} aenean lacinia lacinia sapien nec fermentum. {module name="thename" class="thelist" method="show" parameter1="first parameter" parameter2="second parameter" parameter3="third parameter"} donec ligula lectus, egestas et molestie ac, tristique id mi. donec sed scelerisque leo.
i using 2 regex:
$ex = preg_match_all("/{((?:module|block).*?)}/sm", $text, $matches);
preg_match_all ( '/^{module\s+|\g(name|class|method)=("[^"]+"|\'[^\']+\'|\s+)(?:\s+|(?=}$))/i', $module, $matches );
the first 1 items in news article. second 1 splits every block , modules in array.
the question: second regex doesn't parameters one! need parameters editor writes in content of news article.
you not searching them.
^{module\s+|\g(name|class|method|parameters)=("[^"]+"|\'[^\']+\'|\s+)(?:\s+|(?=}$)) ^
you search term parameters
followed =
, not exist. named them parameter1
, on. change
^{module\s+|\g(name|class|method|parameter\d+)=("[^"]+"|\'[^\']+\'|\s+)(?:\s+|(?=}$))
should you.
Comments
Post a Comment