Reputation: 271
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
Upvotes: 2
Views: 5371
Reputation: 163207
The data that you want seems to be after the first colon. You can match all before the first colon using a negated character class [^
Note that you don't have to escape \:
^[^:]+:\W*(.+)$
The pattern matches:
^
Start of string[^:]+:
Match 1+ times any char except :
, then match :
\W*
Optionally match non word charcters(.+)
Capture in group 1, matching 1+ times any char$
End of stringIf the format of the data is always like that, a more strict pattern could be matching 3 times an asterix and start the capture group with matching a word character.
^\w+\s+:\s+\*{3}\s+(\w.*)$
Upvotes: 3
Reputation: 9284
You are including the :
and ***
that's in the group so they will come in the output.
This should work:
.+\:\s\W+(.+)$
Upvotes: 4