regexadblogcat

Case insensitive operator does not work in logcat


In Android logcat there is an option for specifying regex filter:

-e, --regex=<expr>          Only print lines where the log message matches <expr> where <expr> is
                              an ECMAScript regular expression.

It works okay with regex like this:

adb logcat -e ".*cam.*"

however if I modify it to make it case insensitive it stops working altogether:

adb logcat -e "(?i).*cam.*"

The only workaround is this:

adb logcat -e ".*[cC][aA][mM].*"

But it's not preferred since it takes so long to write, I want to make a bat file that will take user input and then auto run filter on logcat, with last syntax it's close to impossible to program.

Is there any other way to specify case insensitive in regex? Android has no grep so can't use that approach.


Solution

  • Yes, Android don't have grep option to filter ignore case.
    But there is a way to do that.

    This is not an exact solution. But this is an alternative to filter adb log with case insensitive configuration.

    If we use Git Bash on Windows System then we may use grep option.

    I tried that way in my system and it's working perfectly.

    ./adb.exe logcat | grep ".*[cC][aA][mM].*"
    or
    ./adb.exe logcat | grep -i ".*cam.*"
    

    enter image description here