How to read multiple lines with specific keyword using regex from textfile

Hello Guys,

I am facing issue with the Regex (regular expression)
I need to take next line or single line after the String “Beneficiary ” ,it is working fine when i scrap another String “Class:” line with the
regex --> :arrow_down_small:
System.Text.RegularExpressions.Regex.Match(Result,"(?<=(Class: )).*").Value

But, When it comes to read next line after “Beneficiary” its not working what would be the regular expression

Need some help

Thanks in advance

welcome to uipath community
hope this text is in a txt file
–if so use READ TEXT FILE activity and get the output with a variable of type string named str_input
–now use a ASSIGN activity like this
str_lines = String.Join(" ",str_input.Split(Environment.Newline.ToArray()))

now use a assign activity like this
to get the Beneficiary
str_beneficiary = system.Text.RegularExpressions.Regex.Match(str_lines,"(?<=Beneficiary).*(?=Notice Type)").ToString.Trim

and for class
str_class = system.Text.RegularExpressions.Regex.Match(str_lines,"(?<=Class:).*(?=Valid)").ToString.Trim

Cheers @Parthiban.VD


Cheers @Parthiban.VD

@Palaniyappan Thank You so much for response. I am tried that regex method i am getting the following-output, The string “Beneficiary ” name o/p comes along with Notice Type also. Its possible to get the exact "Beneficiary name " only??

@Pradeep_Shiv Thanks for your response

1 Like

i actually modified to this in next few seconds once after posting
kindly retry this it works fine for me buddy

Cheers @Parthiban.VD

@Palaniyappan Thanks once agin, Its working fine :slightly_smiling_face: :100:


Cheers @Parthiban.VD

1 Like

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