How to filter multiple words in Android Studio logcat

ぃ、小莉子 提交于 2020-02-18 05:45:29

问题


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.


回答1:


You should use a grouping construct:

(Encoder|Decoder)

Actually, you can just use

Encoder|Decoder

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

See Character Classes or Character Sets:

With a "character class", also called "character set", you can tell the regex engine to match only one out of several characters. Simply place the characters you want to match between square brackets. If you want to match an a or an e, use [ae].

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

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.

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.



来源:https://stackoverflow.com/questions/34770159/how-to-filter-multiple-words-in-android-studio-logcat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!