Split String - after time and before dashes

I have the following string (its a comment box):
image

I need to retrieve the first message after the date and time and ending with the dashed line ----------.
Can anyone guide on how to split it.
Thanks.

You can use the Split command for doing this. ErrorMsg is the variable holding this message.

Split(ErrorMsg,“–”)[0]

@chauhan.rachita30 Try using regex

Encountered the following exception.*[\n\r]+.*

@chauhan.rachita30 Use the below one, it would work. Check the attached workflow

Example.zip (3.0 KB)

Variable of type string Output = System.Text.RegularExpressions.Regex.Match(Input, "Encountered\s+the\s+following\s+exception.*[\n\r]+.*").ToString

Input

Capture

Output

Capture1

Hey @chauhan.rachita30,

  1. You can assign the text in one variable.
  2. In the second variable you can assign System.Text.RegularExpressions.Regex.Match(strText,“exception.[\n\r]+.”).Groups(0).ToString
    where strText is the whole text.
    image

Thanks,
Sanjit

the small Pattern:
Encountered[\s\S]*?(?=\-{3,})

It can start with anything, not specifically “Encountered”. Thanks

It can start with anything, not specifically “Encountered”. Thanks

just share with us some more patterns with the variations. Thanks

It can be any message, I just need the first message after the date and before the dashed line.

better with samples, but you can try following quick shot:
grafik
refering to group 1

grafik
strPattern = (?:[\d\/\: APM]+)([\s\S]*?)(?=\-{3,})

strResult =
System.Text.RegularExpressions.Regex.Match(yourTextVar, strPattern).Groups(1).Value

1 Like

Thanks a ton!!!

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