I have to find a set of Exception names from my events. Below are the sample text and its corresponding Regular expression which I am trying
Sample Text:
1. Caused by: javax.transaction.TransactionRolledbackException:
2. Caused by: com.gtnexus.database.exception.NoEntryAffectedException:
Expression used:
rex field=_raw "Caused by: (?P^.(.+?)):"
Expect Result:
"TransactionRolledbackException"
"NoEntryAffectedException"
With my above regex I am getting "javax.transaction.TransactionRolledbackException" but I need only the exception name as "TransactionRolledbackException"
Could you please help me on this
Based on nittala answer:
rex field=_raw "Caused\sby\:\s.+\.(?<ExceptionName>[^:]+):"
This takes in consideration also an error that doesn't end with "Exception" word
(?[A-Z].*:)
(?
Assigned ==>
Starting Char ==> [A-Z]
Followed by any no char ==> .*
End with : ==> :
)
you get results like below
Match 1
Status= TransactionRolledbackException:
Match 2
Status= NoEntryAffectedException:
Based on nittala answer:
rex field=_raw "Caused\sby\:\s.+\.(?<ExceptionName>[^:]+):"
This takes in consideration also an error that doesn't end with "Exception" word
Wow! Thankyou!!
Hello, give this a try:
Note: I am assuming that exception name is always preceded by period .
rex field=_raw "Caused\sby\:\s.+\.(?<ExceptionName>\w+Exception):"
Tested here.
Thankyou for the response.
Both the answers by @nittala_surya and @andreacefali are useful. Thankyou for the quick help