Search code examples
regextext-extraction

Regex to extract text after a pattern


I am trying to extract the Error Messages from loader output like below :

LOADER_ERROR : *** Failure The UserId, Password or Account is invalid., attempts:1
LOADER_ERROR : *** Time out waiting for a response.

Expected Output :

Failure The UserId, Password or Account is invalid., attempts:1
Time out waiting for a response.

With the below regex, I am able to extract everything after the last occurrence of ': ' character.

  .+(\:\s.+)$

Output :

: *** Failure The UserId, Password or Account is invalid., attempts:1
: *** Time out waiting for a response.

How do I strip ': ' or '*** ' at the beginning from the output ?

Thanks for any assistance


Solution

  • You are including the : and *** that's in the group so they will come in the output. This should work:

    .+\:\s\W+(.+)$
    

    Check its demo here.