System.Text.RegularExpressions.Regex not working - Trying to RegEx to find a text after a specific word in a large string


I have a regex statement that works outside of UIPath but when I put it in the assign activity as System.Text.RegularExpressions.Regex(Client,“.Member Name:\s([^\n\r]*”)) it gives me an error.

For Example “Client” is text from a whole PDF page and this RegEx is finding just the text thats after “Member Name”, where in the document that shows up.

Can you help fix this error?

What error is it giving?
Try to import the namespace and use invoke of just the function instead of calling whole namespace. You might be making mistake in syntax.

I can’t run the workflow cause the error is “Compiler errors encountered processing expression " System.Text.RegularExpressions.Regex(Client,“. Member Name:\s ([^\n\r]*”))” End of Expression Expected.

Namespace is already imported, when you say to use invoke - do you mean the invoke method or invoke code and how would you get the output to a variable from using those activities?

Your syntax for the assign statement should be as below.

1 Like

That lets me run the BOT and get this error: image

I put in this in System.Text.RegularExpressions.Regex.Match(Client,“.Member Name:\s([^\n\r]*”)).Value and then the assign throws the first error I was getting and wont let me run it.


Instead of above try like below

System.Text.RegularExpressions.Regex.Match(Client,“. Member Name:\s [^\n\r]*”).Value

Your syntax is wrong. Try below syntax
System.Text.RegularExpressions.Regex.Match(Client,“.Member Name:\s([^\n\r])*”).Value

1 Like

Both of those return nothing as values. My original regex works on Here is an example of the value I am trying to regex. I want the member name and employee ID.

2018 Distribution (including true up for 2017)
Information about the Partnership
Taxpayer ID: XXXXXXX
Partnership Name: XXXXXXX
Partnership Address: XXXXXXXXX

Information about the Member

Member Name: John Smith

Employee ID: 111111111

Member Address: XXXXXX

Regex used: Member Name:\s[^\n\r]*

1 Like

That worked! Thank you!

One more Question if the text is this: what would be the regex I would use to just get the name “John Smith”?

Member Name:
John Smith

Employee ID:

Member Address: XXXXXX

I Faced the same issue, it worked for me.

hey Vinutha Great work Can u show me how to extract using regex for the same but for multiple matches System.Text.RegularExpressions.Regex.Matches()
Can u please consider this

HI @Kunal_Kumar

You just need to add the index to get the value that is

System.Text.RegularExpressions.Regex.Matches()(0).Tostring will get you the value that matches first