I have a regex, .*(key|secret).*=.*, any lines which include key or secret will be matched, but i want ignore lines which include words like log, test or special characters like // , /*, *.
Who has any ideas for this problem? Thanks!
>Solution :
You could add a negative lookahead assertion to your current regex pattern to blacklist any words/symbols which you don’t want to appear in any matching line:
^(?!.*(?:\b(?:log|test)\b)|[*/]).*\b(?:key|secret)\b.*=.*$
^^^ disallow "log", "test", and special symbols
^^^ match "key" or "secret"