如何在Android Studio Logcat中过滤多个单词 [英] How to filter multiple words in Android Studio logcat

查看:349
本文介绍了如何在Android Studio Logcat中过滤多个单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想在logcat中看到几个字.换句话说,只是一个给定的标签.我试图启用 Regex 并键入 [Encoder | Decoder] 作为过滤器,但是它不起作用.

I want to see just a couple of words in logcat. In other words, just a given tags. I tried to enable Regex and type [Encoder|Decoder] as filter, but it doesn't work.

推荐答案

您应使用分组构造:

(Encoder|Decoder)

实际上,您可以使用

Encoder|Decoder

如果使用 [Encoder | Decoder] ,则会创建与任何单个字符 E n c ... | D ...或 r .

If you use [Encoder|Decoder], the character class is created that matches any single character E, n, c... |, D... or r.

请参见 字符类或字符集 :

使用字符类"(也称为字符集"),您可以告诉正则表达式引擎仅匹配几个字符中的一个.只需将要匹配的字符放在方括号之间.如果要匹配 a e ,请使用 [ae] .

另一个必读的内容肯定是 带有竖线或管道符号的替换 :

Another must-read is certainly Alternation with The Vertical Bar or Pipe Symbol:

如果要搜索文本文本 cat dog ,请用竖线或竖线符号将这两个选项分开: cat | dog .如果需要更多选项,只需展开列表: cat | dog | mouse | fish .

If you want to search for the literal text cat or dog, separate both options with a vertical bar or pipe symbol: cat|dog. If you want more options, simply expand the list: cat|dog|mouse|fish.

使用 (...) 时,您告诉regex引擎进行分组字符/子模式的序列(对于捕获的字符/子模式,子匹配存储在内存缓冲区中,您可以通过反向引用和不捕获的(?:...)来访问它们code>您只能将子模式分组):

When using (...) you tell the regex engine to group sequences of characters/subpatterns (with capturing ones, the submatches are stored in the memory buffer and you can access them via backreferences, and with non-capturing (?:...) you only group the subpatterns):

通过将正则表达式的一部分放在圆括号或括号内,您可以将正则表达式的该部分组合在一起.这样,您就可以将量化器应用于整个组或限制

By placing part of a regular expression inside round brackets or parentheses, you can group that part of the regular expression together. This allows you to apply a quantifier to the entire group or to restrict alternation to part of the regex.

这篇关于如何在Android Studio Logcat中过滤多个单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆