I'm searching for a regex that I could se in Android Studio custom filter on logcat window. The window look like this :
here is a log sample that I need to filter :
08-06 15:46:13.883 27841-12352/tv.me.sdkapptest D/me#BADTAG﹕ process
08-06 15:46:13.883 27841-12352/tv.me.sdkapptest D/me#BADTAG﹕ processUri
08-06 15:46:13.884 27841-12352/tv.me.sdkapptest D/me#BADTAG﹕ About to create doc from InputStream
08-06 15:46:13.886 27841-12352/tv.me.sdkapptest D/me#BADTAG﹕ Doc successfully created.
08-06 15:46:13.887 27841-12352/tv.me.sdkapptest D/me#BADTAG﹕ About to merge doc into main doc.
08-06 15:46:13.887 27841-12352/tv.me.sdkapptest D/me#XmlTools﹕ xmlDocumentToString
08-06 15:46:13.895 27841-12352/tv.me.sdkapptest D/me#BADTAG﹕ Merge successful.
08-06 15:46:13.895 27841-12352/tv.me.sdkapptest D/me#BADTAG﹕ Doc is a wrapper.
08-06 15:46:13.905 27841-12352/tv.me.sdkapptest D/me#BADTAG﹕ processUri
08-06 15:46:13.905 27841-12352/not.to.me D/me#BADTAG﹕ begin
08-06 15:46:13.905 27841-12352/tv.me.sdkapptest D/me#MainActivity : so
I want to keep line with tv.me.sdkapptest
that not contain me#BADTAG
or me#XmlTools
As a result, only the last line should match. I'm already using this : ^((?!(#BADTAG)|(#XmlTools)).)+$
but is does not remove not.to.me
lines.
答案 0 :(得分:1)
您可以使用以下正则表达式:
^(?!.*(?:me#BADTAG|me#XmlTools))
请参阅demo
正则表达式意味着
^
- 行首(?!.*(?:me#BADTAG|me#XmlTools))
- 如果该行中包含me#BADTAG
或me#XmlTools
如您所知,要仅显示与某个包相关的日志条目,必须将此包名添加到Logcat过滤器对话框中的包名称字段。
答案 1 :(得分:0)