I am looking to replace a brand name in HTML but I want to avoid breaking brand mentions that might be part of a CSS class. I decided to try to allow only matches preceded by a space or a comma, but could be followed by anything except a dash, an underscore or a dot. But because a trailing dot could be a legitimate match, I want to allow it if t's followed by a space.
So far my regex looks like this:
([ ,])(brandname|brand name)(?![-_])
but I am stuck with how to negative match the trailing . but allow trailing .\s
Editing to give a few examples:
true: brand name. something
false: brandname.something
true: ,brand name. something
false: .brandname
true: brandname something
true: brandname,something
false: brand name-something