https://kotlinlang.org logo
#announcements
Title
# announcements
l

Leszek Janiszewski

06/25/2019, 12:31 PM
Hey, does anybody know how to filter out logcat messages that match regex
\d{3}\.\d{10},
? Negative lookup
(?!\d{3}\.\d{10},)
doesn’t seem to work here for some reason. The example message looks like this
2019-06-25 13:45:22.286 13313-13351/com.secretproject.alpha I/Http Response: │       247.2145208724,
Filtering out based on TAG is not a feasible solution, because I need this to log out other responses.
d

Dico

06/25/2019, 1:38 PM
Did you try
.*
in front of the negative look ahead?
r

Ryan Mentley

06/25/2019, 9:57 PM
neither of those are correct, that's not how lookaheads work
(?!\d{3}\.\d{10},)
matches all strings, because you're looking for a string that contains a blank string that is followed by a number in that format
which is...everything. it'll just match a blank string somewhere in the string
Is the number at the end of the string? if so, assuming that Studio actually supports lookbehinds, you could do something like
(?<!\d{3}\.\d{10},)$
disclaimer: I didn't test that
but that would be "the end of the line, assuming it's not preceded by something matching `\d{3}\.\d{10},`"
d

Dico

06/25/2019, 10:03 PM
Right so you need to have
^.*?(NL)$
where NL is the negative lookahead
r

Ryan Mentley

06/25/2019, 10:05 PM
that would also work, but only if it's at the end of the string
d

Dico

06/25/2019, 10:07 PM
I reckon you dont need negative lookahead at all
Doesnt matter whether the number thing is in the matched text
r

Ryan Mentley

06/25/2019, 10:14 PM
honestly though your best bet is probably to do this from the command line and then use
grep -v
or something
l

Leszek Janiszewski

06/26/2019, 8:32 AM
thanks for the help guys!
2 Views