Looking to preserve inner nested brackets when replacing brackets. If possible to make many nested layers work that would be great, if not just nested once is fine.
(if money>5 and (times + total_cash >266))[something]
(if times + total_cash >266)[something]
{if money>5 and (times + total_cash >266)}[something]
{if times + total_cash >266}[something]
A naive attempt doesn't seem to work that well:
str.replace(/\(if(.*?)\)]/gi, '{if $1}')