I have a initialmsg ,
let initialmsg = "zavio, invitation sent to {#arg#} {#arg#} &academy!"
let msg = "zavio,\s?invitation\s?sent\s?to\s?.{0,2} .{0,2} &academy!"
After manipulation using regex it has been converted in to msg. Now I need to remove special characters in the sentence except \s?. How can I write the condition ?
var splitters= /{#arg#}|(|[!-\/:-@[-`{-~])/gi;
initialmsg= initialmsg.replace(/(^|.)\s($|.)/g, (x, g1, g2) => (x == "} {" ? x : g1 + "\\s?" + g2));
msg= initialmsg.replace(splitters, (x,y) => y ? "" : ".{0,2}");
which produces the above msg.
let msg = "zavio,\s?invitation\s?sent\s?to\s?.{0,2} .{0,2} &academy!"
If i try to include in the ternary operation,
var splitters= /{#val#}|(([/\s!?])|[!-\/:-@[-`{-~])/gi;
msg = initialmsg.replace(splitters, (x,y,z) => y ? "" : x ? ".{0,2}" : "\\s");
it produces different result. Please help me, My final result should be,
msg = "zavio\s?invitation\s?sent\s?to\s?.{0,2} .{0,2} academy"