Anthony: *>As I mentioned earlier, replace BADWORDS.match(value) with BADWORDS.search(value). *. Sorry I missed that, you made it perfectly clear...
*> add word boundaries r'\b' to the RE, >.. Though he said he explicitly did not want to do that. *. Sorry I wasn't clear on that.... but the word boundary will be useful to me in future. Thanks all ~Rob I will return just a True, or False with this, then add a validator to the username for registration, then do some testing, and post complete solution, moving code to the proper place, with conditional etc. *Note*: Google doesn't allow bad words for usernames, but rather than lecture you on bad words, they just say Username:* frig*you123 is already taken... and you can keep trying, like * frig*you123vvzz.yeearbob and Google will just tell you that name is taken, which I don't think it is :) *Here is my code, now working... * # this import is required in web2py import base64, re #let's assume: # username can't contain spaces, just a-z and periods # 'frig' is a very bad word # 'sadf' is a racial slur # so even if a person's name as frig, or asdf in it # we will not let them use that. # asdf - is a bad username # asdfyou - is a bad username # youasdf - is NOT a bad username, but IT SHOULD BE. badlist = ['frig', 'asdf', 'etc'] BADWORDS = re.compile(r'|'.join(badlist)) class IS_BAD: def __init__(self,error_message='bad word is contained in username'): self.error_message = error_message def __call__(self,value): if BADWORDS.search(value): return (value,self.error_message) return (value, None) --