MyBB Community Forums

Full Version: How to make a table mycode with 2 variables
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, can anyone tell if it is possible to make the following mycode work in one mycode 'expression':
  • [table][/table] Default - aligned to the left with no header
  • [table align=center][/table]
  • [table header=yes][/table]
  • [table align=center header=yes][/table]

At the moment the user is forced to enter the variables.
Expression:
\[table=(left|center) header=(yes|no)\](.*?)\[/table\]
Replacement:
<div class="post-table $1 header-$2">
$3
</div>
Example:
[table=center header=yes]...[/table]

Yes, I know I'm using a div. For technical reasons I was forced to use a div, as <td> and <tr> broke the layout if it wasn't wrapped in <table>.
\[table(?: )?(?:position="(left|center)")?(?: )?(?:header="(yes|no)")?\](.*?)\[\/table\]

This should do what you want I believe, don't think it supports nesting though.
Thanks! That's great. Yeah, I don't need tables inside tables anyway.

@Edit:
Any way to make:
position="center" header="yes" and header="yes" position="center" work?
Or does position have to always be first?

Thanks
It's certainly possible with regex positive lookahead, however using them in MyBB is giving me some trouble. If you're able to figure something out with them let me know. Smile
I wish I could help, it's pretty complicated :z