RegExp - Swearing words filter - Exact match, no partial match
Hello,
I am working on a Swearing words filter which works find except that it replaces even when the match is partial instead of the exact match word. Let me explain.
I have a list of offensive words but for the purpose of the example let say that my list contains only one single offensive word and with it I build the following RegExp...
var regexpString:String = "(a55)";
patern = new RegExp(regexpString, "g|i");
..this filters as follow...
var str:String = "a55";
var filteredStr:String = str.replace(pattern, "**"); //will trace out ***, which is fine for me.
var str:String = "helloa55";
var filteredStr:String = str.replace(pattern, "**"); //will trace out hello*** which is not what I am looking for.
...this is what I would like to do differently, when I pass "helloa55", I would like to get the word without filtering because it is not a match of the offending word, I would like to get back the word helloa55 and not hello***.
I know I could use a function that will analyse the word and do all the necessary check but I was wondering if there is any simple and straighforward way of doing this, some kind of flag to add to the RegExp that will tund partial match to exact match.
Thank you.
