notepad++ - A Regex that search for lines that contains a string, and not contains another string -
i want analyze error log. decided search error header in error log using notepad++ can first line of errors on search result (which contains short description error) determine if need deeper it. error log apparently full of 'useless' error log 1 kind of event, 90% of it, kinds of hide real error, searching needle in haystack.
so example made error log:
error on server1: network connection reset. detail: client gone. error on server2: network connection reset. detail: client gone. error on server1: network connection reset. detail: client gone. error on server1: null pointer error. detail: object 'cart' not exists. stacktrace: @ updatecart function @ addproducttocart function error on server2: network connection reset. detail: client gone. error on server2: io error detail: resource on url (www.example.com/data.xls) not exists. error on server2: network connection reset. detail: client gone.
i want create regex on notepad++ search search line contains string "error on" not contain "network connection reset", search result contain:
error on server1: null pointer error. error on server2: io error
how can that? i've read somewhere inverse matching on regex hard , unusual, it's possible. thanks.
btw, i've tried other way this, finding "error on" + (.*)
+ "network connection reset", replace empty string, next time search "error on", not appear. error log becomes scrambled weird symbols after search , replace, , notepad++ kinda crashing after that. don't know. never have luck search , replace on notepad++ using regex.
i use negative lookahead.
^(?!.*?\bnetwork connection reset\b).*\berror on\b.*
Comments
Post a Comment