I need to validate input: when user type one of 3 words from list (array is in js file), I need to have error (in this case below, if user type test1, test2, or test3 you will see error, otherwise everything should be fine)
file.html
<input type="text" ng-pattern="regexPatter" />
file.js
var array = ["test1", "test2", "test3"]
var excludeWords = array.join('|')
$scope.pattern = new RegExp("\b(?!\b" + excludeWords + "\b)[a-zA-Z']+\b");
I found that this regex pattern should work, but unfortunately, it's problem with '\b' because js misinterprets this char.
How can I replace it? Maybe is another solution for this case? I can't just put this regex pattern in html, because I should add variable.
Thanks for any tip!