Ahh yes, good point. This should work correctly now:
if ($regex($1-, /[color:red](?:^|\s)[/color]((?:[^\w\s]|_)*)p(?1)e(?1)n(?1)i(?1)s(?1)[color:red](?:\s|$)[/color]/Si)) { profanity10 }
The two bits in red have been added. They simply check that there is a whitespace character or the beginning/end of the string at the beginning/end of the word respectively.