2016-10-30, 10:59 PM
I want to do this
regex for mycode
replacement for mycode
This does not define how to do this
https://community.mybb.com/thread-12008.html
I tried something like this but it doesnt work for the replacement
regex for mycode
\[test=(.*?)\](.*?)\[/test\]
replacement for mycode
<button title="image1" type="button" onclick="if(document.getElementById('spoilerbtn') .style.display=='none') {document.getElementById('spoilerbtn') .style.display=''}else{document.getElementById('spoilerbtn') .style.display='none'}">$1</button>
<div id="spoilerbtn" style="display:none"> $2</div>
as is it works. But i want the [test=???] to be optional. As is it must be there or it does not work. I want it to be optional.This does not define how to do this
https://community.mybb.com/thread-12008.html
I tried something like this but it doesnt work for the replacement
<?php if ($1 === null){$1 = "Click to expand/condense"}?>
<button title="image1" type="button" onclick="if(document.getElementById('spoilerbtn') .style.display=='none') {document.getElementById('spoilerbtn') .style.display=''}else{document.getElementById('spoilerbtn') .style.display='none'}">$1=defualt</button>
<div id="spoilerbtn" style="display:none"> $2</div>
I add a ? in front of the optional value in the regex...but then the button has no text at all if there is no argument given.