Extract certain range of information from a text file

2019-11-15 16:28:54.274 [INFO] gip.Bghivt:204 - Exit GIPCustomConnectorImpl: removeAppRoleFromAccount with error for Change Request No → UAT_IAMDET51873
2019-11-15 16:28:54.275 [INFO] org.mule.api.processor.LoggerMessageProcessor:193 - AFX_OUT redirect flow invoked…
2019-11-15 16:29:04.356 [INFO] gip.Bghivt:164 - Entry inside prepareEmployee
2019-11-15 16:29:04.356 [INFO] sg.com.income.connector.gip.GIPConnectorHelper:192 - Exit inside prepareEmployee
2019-11-15 16:29:04.356 [INFO] sg.com.income.connector.gip.GIPCustomConnectorImpl:179 - Entry GIPCustomConnectorImpl: removeAppRoleFromA
2019-11-15 16:29:04.357 [INFO] gip.Bghivt:266 - Entry: getRequestBodyForRemoveAppRole
2019-11-15 16:29:04.357 [INFO] sg.com.income.connector.gip.GIPConnectorHelper:67 - request message → {“userId”: “s750730”,“userName”: “”,“roleId”: “245”,“modifiedBy”: “IAM”}
2019-11-15 16:29:04.401 [INFO] sg.com.income.connector.gip.GIPConnectorHelper:92 - Message is Server returned HTTP response code: 526 for URL:
2019-11-15 16:29:04.402 [ERROR] .gip.Bghivt:199 - Error details in GIPCustomConnectorImpl: removeAppRoleFromAccount. Stacktrace-> java.lang.Exception: Error occurred while calling the service →

The above information is an example of what I want to extract.
How can I extract this whole list of information from first sentences till the last sentences?

Hi,
what is the source that you are extracting from?

a text file that includes all the log information.

I am using the read text file as a dependency for extracting the message

you extract it if you know the staring word and the ending word using regex.

in this case, may I know what is the difference between matches and is match activities and between these two activities, which one is prefer for my case

you should use matches in this case.

Hi, I am completely do not know how to extract this range of information using regex, May u help me further?

My starting word is “error”
and ending word is “Error occurred”

can i see the text file?

(^error(?s)((?:[^\n][\n]?)+)Error occurred$)

try this

It seems like I could not upload the text file due to I am a new user…

is there any alternate way by looking at the above information, I can manage to get the answer?

Did you try

yup.

System.Linq.Enumerable+d__97`1[System.Text.RegularExpressions.Match]

This is the result I got. I am still thinking of turning this to the result shown above :sweat_smile:

how are you trying to out put the result

I am trying to use for each activities hoping it will display a readable result

can you show the expression which you were trying to display

the screenshot of your workflow.

you should change the type in the foreach and also the way of accessing group is there.

Hi, thanks for your help. I had found my result!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.