I have this JavaScript code below to remove spaces in the given words (ستاک ئەڤەفلۆو), and I tried it in Console.log, but it has a problem.
var text = "ئایا ستاک ئەڤەفلۆو مانای چییە؟ دووبارە ستاک ئەڤەفلۆو مانای چییە؟";
text = text.replace(
new RegExp("(^|\\s|_|«|»|\\[|\\(|\\<|\\>|\\')(ستاک ئەڤەفلۆو)(?= |«|»|\\.|،|_|\\]|\\s|\\:|\\)|\\<|\\>|؟|\\'|\\!|$)", 'g'),
function (x) { return x.replace(/ /gi, ''); } // 'i' is just to trick bidi algorithm on code view
);
The following is the wrong output:
ئایاستاکئەڤەفلۆو مانای چییە؟ دووبارەستاکئەڤەفلۆو مانای چییە؟
Which removes the space before the given string, so it merges the given string with the previous word.
The output should be:
ئایا ستاکئەڤەفلۆو مانای چییە؟ دووبارە ستاکئەڤەفلۆو مانای چییە؟
Thanks!