Here is my input code snippet:
(((text(text here))) AND (test3) Near (test4) NOT (test5) NOT (Test6)),((tttt,tttt)),((and,lol)),((hbhbhbhbhbh))
This is the output I get:
(((text(text here))) AND (test3) Near (test4) NOT (test5) NOT (Test6) (tttt,tttt) (and,lol) (hbhbhbhbhbh))
The result that I was expecting to see:
(((text(text here))) AND (test3) Near (test4) NOT (test5) NOT (Test6) ((tttt,tttt)) ((and,lol)) ((hbhbhbhbhbh))
I need to replace the commas with whitespaces when finding this specific string pattern: ),(
Check out the DEMO below:
var txt = "(((text(text here))) AND (test3) Near (test4) NOT (test5) NOT (Test6)),((tttt,tttt)),((and,lol)),((hbhbhbhbhbh))"
var finalResult = txt.replace(/[)],[(]/g, " ");
console.log("Result:", finalResult);