How to remove text from a string
Posted: Fri Jan 18, 2019 2:38 pm
I can't get this code to work
var NickName = "Hello, this is Mike (example) xx "
var NoNickName = "didn't work"
NoNickname = NickName.replace(/ *\([^)]*\) */g, "");
AkelPad.MessageBox(0, NoNickName + " " + NickName, "Remove NickNames", 64 /*MB_ICONINFORMATION*/);
// Result should be
// "Hello, this is Mike"
// Here, we are using regular expression / *\([^)]*\) */g that finds the characters inside brackets (in this case small round brackets) and replace them with empty string.
var NickName = "Hello, this is Mike (example) xx "
var NoNickName = "didn't work"
NoNickname = NickName.replace(/ *\([^)]*\) */g, "");
AkelPad.MessageBox(0, NoNickName + " " + NickName, "Remove NickNames", 64 /*MB_ICONINFORMATION*/);
// Result should be
// "Hello, this is Mike"
// Here, we are using regular expression / *\([^)]*\) */g that finds the characters inside brackets (in this case small round brackets) and replace them with empty string.