Try '^((?!(down|error)).)*$'
This ensures that it matches any characters at the beginning of a string, not followed by 'down'
or 'error'
, as many times as necessary. Note that this RegEx is case sensitive and will match a string with 'Down'
.
Your RegEx would not really make any sense because it includes a negative lookahead but nothing to look ahead from. Thus, it would match 0 characters (or the empty string ''
), not followed by any number of characters and then 'down'
or 'error'
. Even if you had the characters 'down'
or 'error'
in your string, you would still match within the pattern 'down'
or 'error'
for your RegEx.
NOTE: Negative assertions are intended for smaller rules, not for whole strings. The most commonly used example is to find a q
without a u
after it, such as in sheqalim
. In this case, you might want to find the position of the q
. However, with your case, it seems like you just want to determine whether 'down'
or 'error'
are contained in your string, with which it is more efficient and simpler to use a built in function, if whatever language you are using has one. If it doesn't, it would also be easier to see if you can match 'down'
or 'error'
and negate that. The RegEx I provided should be a last resort.