Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to close all opening square bracket tags that aren't closed?
    primarykey
    data
    text
    <p>Ok, so I have a message, can a regular expression be used to determine if there are square brackets within it, and if so, determine if they aren't closed.</p> <p>For example, and opening square bracket is like this: <code>[code]</code></p> <p>Closing is like this: <code>[/code]</code></p> <p>But there are way more than just the code bbc codes that can be within square brackets.</p> <p>What I'd like to be able to do, is use a variable that contains the entire message, and somehow determine if there are any words within square brackets that do not have a closing tag, which is denoted by: <code>[/</code> the word, and than <code>]</code> Opening tags ofcourse start with <code>[</code> the word, and than end with <code>]</code></p> <p>So, if I have something like this within a variable:</p> <p>Ok, so here is the overall script.php file with ALL of the Recent Module code in it. So we start with the Main function for retrieving the $params from the functions parameter...</p> <pre><code>[code]function module_recent($params) { global $context, $txt; // Grab the params, if they exist. if (is_array($params)) { </code></pre> <p>It would know that <code>[code]</code> was not closed off and add it at the end <code>[/code]</code></p> <p>But also, if I have something like this:</p> <pre><code>[table] [tr][td]Hello World[/td][/tr] [tr][td]This is not closed... </code></pre> <p>It should know that <code>[table]</code> and <code>[tr]</code> and <code>[td]</code> is not closed and it should add the closing tags into it at the end in this order:</p> <p><code>[/td]</code> and than <code>[/tr]</code> and finally <code>[/table]</code></p> <p>But there are also other tags like <code>[list][li][/li][/list]</code></p> <p>Would be great if I could populate all of the tags that can be within square brackets within an array and than call upon a function that would check if it has both opening and closing tags, that way it wouldn't effect non-bbc code tags that people put into messages just cause.</p> <p>Can anyone give me a hand on a Reg. Ex to do this with? Atleast if someone can help me get started on this that would be excellent.</p> <p>Thanks guys :)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload