JSFiddle - React, Tailwind, and code Playground

by cancerbero_sgx

JavaScript

var keywordsFormatter = function(keyword)
{    
    var patt1 = /[\(\)\*\"\:]{1}/g; //characters that cannot appear at any location
    var patt2 = /^[\-\+\~]{1}/g; //characters that cannot appear at the begining
    var replaceWith=""; //replacement for invalid chars
    return keyword.replace(patt1, replaceWith).replace(patt2, replaceWith); 
}

var str = "balbla((lkajsd("; 

alert(keywordsFormatter(str));