I want to search a string and see if it contains any of the following words: AB|AG|AS|Ltd|KB|University
I have this working in javascript:
var str = 'Hello test AB';
var forbiddenwords= new RegExp("AB|AG|AS|Ltd|KB|University", "g");
var matchForbidden = str.match(forbiddenwords);
if (matchForbidden !== null) {
console.log("Contains the word");
} else {
console.log("Does not contain the word");
}
How could I make the above work in python?
University|A[BGS]|Ltd|KBorLtd|University|[AK]B|A[GS]... But when you need to change it, that's a hell to maintain! :)