Pitel
Pitel

Reputation: 5393

How to filter multiple words in Android Studio logcat

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.

Upvotes: 48

Views: 29730

Answers (4)

Alex Egli
Alex Egli

Reputation: 2064

For latest logcat (Android Studio Hedgehog) I used tags.

message:Encoder message:Decoder message:"A multi word phrase to search"

Reference: https://developer.android.com/studio/debug/logcat#logical-operators

Upvotes: 0

Tom
Tom

Reputation: 7804

For the new logcat you need spaces between pipes, eg.

package:mine AuthenticationHelper | identify | migration

Upvotes: 18

Farid Savad
Farid Savad

Reputation: 163

you can just use Encoder|Decoder and must check Regex CheckBox too

Upvotes: 0

Wiktor Stribiżew
Wiktor Stribiżew

Reputation: 626690

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.

Upvotes: 73

Related Questions