No matter what you do to expand the tag system, you need to: 1. Define the tag and 2. Replace it with equivalent HTML.
Even if you write your own parser in js, at the end of the day you will still have to complete the 2 above steps, so it will not be more extensible than what you have now.
Regex is a tool for specifying if you have no other requirements (for example, replace only inside such an element, but do something else in another element that requires parsing).
You can transfer regular expression calls to a function and simply add regular expressions to this function when you need to extend this function. If necessary on multiple pages, add it to an external js file.
function formatUserContent(text) { text = text.replace(/\*([^\*]+)\*/g, '<b>$1</b>'); text = text.replace(/\_([^\_]+)\_/g, '<u>$1</u>'); text = text.replace(/\-([^\-]+)\-/g, '<s>$1</s>'); text = text.replace(/\[([^\|].+)\|(.+)\]/g, '<a href="$2">$1</a>'); return text; }
After that, expanding a function is as simple as adding
text = text.replace(/\+([^\-]+)\+/g, '<em>$1</em>');
in the body of the function. I doubt that deploying your own final state machine will be easier to spread, just the opposite.
Spending hours on a state machine in the hope that it can save several minutes at some unknown time in the future is just not a good investment ... unless, of course, you want you to write a state machine, in this case forward.
As a side note, I would recommend making your regex even more proof of a fool.
text = text.replace(/\[([^\|].+)\|\s*(http://.+)\]/g, '<a href="$2">$1</a>');
(If you do not have user interface elements that will perform the task for the user)