The pattern
/^((?!PART).)*$/
matches the general pattern ^.*$
, namely anything occurring in between the start and end anchors. However, it also contains a negative assertion (?!PART)
. As written, your pattern asserts that, at each position in the string, the string PART
does not appear when looking forward for four characters.
If you just use this pattern:
/((?!PART).)*/
then it only means that PART
does not occur at any certain point in the string. But as this demo shows, a string such as PART hello world
would match this alternative pattern, and may not be what you want.