Does not contain the string ABC:
^(?!.*ABC).*$
(Reference: https://www.cnblogs.com/wangqiguo/archive/2012/05/08/2486548.html )
Does not contain the string ABC and contains the string XYZ:
^((?!ABC).)*XYZ((?!ABC).)*$
(Reference: https://www.cnblogs.com/mumian2/p/10926361 .html )