This is too long
In that case then instead of trying to support some SPECIFIC individual properties, then expect CSS rules. In other words instead of: [table:border=2]
(which by the way, does not allow you to specify units such as percentages, em, etc.)
you would write: [table border:2px]
For ANY other css rule: [table border:2px;background-color:yellow;color:red]
then you would just need one regex:
to convert it to: <table style="border:2px;background-color:yellow;color:red">
which in my opinion offers more styling options to your table. The expression you would need is: str.replace(/\[table\s*(.*?)\]/ig,'<table style="$1">');
(PS. What is the name of t={}, what {} means?
that is shorthand for var t= new Object()
. There I am just initializing a variable that holds different rules which I then try to match against your input string. So, if you want to support only specific properties, you will need that "long" approach. But if you want to support ANY css rule, the the expression I showed you above will suffice.