This is how I interpret Tekinay’s pattern.
It is adding some additional constraints to the problem presented.
( a ). All lines are supposed to have the basic pattern
( b ). There is no text expected after the basic pattern.
( c ). There is no text expected before the basic pattern.
Accepting these additional restrictions it works! Only BAD patterns get selected. Very elegant.
But let’s say that it is acceptable to have a variable amount of text after the pattern? If the pattern is OK you do not want those lines to be flagged. So we can modify the Teknay pattern. Get rid of the first $. [As best I can tell, the second $ is superfluous and it does not matter whether it is present or not}.
^x#\d{3} \d \w{11}:(*SKIP)(*FAIL)|^.+$
This slight variant is successful in removing the prohibition on text after the pattern. Those lines will not be flagged as bad unless the leading pattern itself is bad. The restriction ( b ) has been removed. It is not perfect in the sense that now it is not the bad pattern that is selected but rather the entire line that starts with the bad pattern. Actually, for my purposes, that is OK.
Let’s say it is acceptable to have text also before the pattern. Perhaps we can just get rid of the initial ^ in the pattern.
x#\d{3} \d \w{11}:(*SKIP)(*FAIL)|^.+$
For reasons that are not clear to me, that does not work. However a slight modification does make this work.
.*x#\d{3} \d \w{11}:(*SKIP)(*FAIL)|^.+$
This variant is successful in removing the prohibition on text before the pattern. The restriction ( c ) has been removed. The entire line that contains the bad pattern, rather than just the pattern, is flagged but, again, that is OK for me.
My remaining problem is the constraint ( a ). My text contains many lines that do not have and are not expected to have the pattern at all. Unfortunately, these all get flagged.
There is a somewhat kludgy solution which is to assume that if there is a problem it is only in one location and then look for this with a very long “OR” Regex pattern. You just look for cases where there is a conflict in a specific location.
(x#\D\d\d \d \w{11}:)|(x#\d\D\d \d \w{11}:)|(x#\d\d\D \d \w{11}:)|(x#\d\d\d[^ ]\d \w{11}:)|(x#\d\d\d \D \w{11}:)|(x#\d\d\d \d[^ ]\w{11}:)|(x#\d\d\d \d \W\w{10}:)|(x#\d\d\d \d \w\W\w{9}:)|(x#\d\d\d \d \w{2}\W\w{8}:)|(x#\d\d\d \d \w{3}\W\w{7}:)etc.
This works except it will not flag the situation where there is more than one error in the pattern.
Finally, I stumbled on this which is still fairly long and kludgy but works. You just sequentially look for an error in the 19 locations of the pattern.
(x#\D.{17})|(x#.\D.{16})|(x#.{2}\D.{15})|(x#.{3}[^ ].{14})|(x#.{4}\D.{13})|(x#.{5}[^ ].{12})|(x#.{6}\W.{11})|(x#.{7}\W.{10})|(x#.{8}\W.{9}) etc.