Help with regex in email body

Hi I am matching some patterns in the email body. It workes in regex101, regextester and uipath in build regex tester. But there is no output.

Test Text:
General Information

Name

rody

Identification Type

Regex expression:
((?<=Name)|).+?(\n)(\n)(?=Identification Type)

Kindly assist, Thank you xoxo

hi @sangasangasanga
may i know what value you are trying to get from this text…
Cheers @sangasangasanga

the next next line after Name
e.g. rody

Fine can i have a sample text of that structure
Cheers @sangasangasanga

It is like that

well i tired to reproduce the same
but

i think we can use split string like this
if text is stored in a variable of type string
in_text_variable = "General Information

Name

rody

Identification Type"
Then we can do like, where out_stringarray is a variable of type string array
out_stringarray = in_text_variable.Split(Environment.Newline.ToArray(),StringSplitOptions.RemoveEmptyEntries)
and you can get the value of Name like this where out_namevalue is a variable of string
out_namevalue = out_stringarray((out_stringarray.indexof(“Name”))+1).ToSting
Cheers

@sangasangasanga

Can you try the below expression.

system.Text.RegularExpressions.Regex.Match(your_input,"(?<=Name\s+)(.+?)(?=\s+Identification)",RegexOptions.Multiline)

1 Like

Works for me tho

I tried your string array, however it says index of not accesible

the output is still blank

@sangasangasanga

I hope out_stringarray is of type array of String here. So, we can’t use IndexOf function to String array.

We will use this function for variable of type String.

varString.IndexOf(“searching String”)

yes I did

You can refer below
Main.xaml (15.8 KB)

@sangasangasanga

Try this:

In Assign, j = out_stringarray(0)((out_stringarray(0).indexof(“Name”))+1).ToString

I tried, the output is just ‘A’ ?

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