How to Extract String with Spaces using Regex

Hi All,

I want to extract data from Email Body in which one filed has space in between the string value. Can anyone help me in getting this please?

Ex : Vendor Name : this is for Test
so here i want to extract Vendor Name value which is " this is for Test".

Hello @Aswini,

Yes, you can extract the value of the field like “Vendor Name” using Regex (Regular Expressions).

Use this Query:-

System.Text.RegularExpressions.Regex.Match(yourEmailBodyText, “Vendor Name\s*:\s*(.*)”).Groups(1).Value

1 Like

Its working Thank u so much

@sagar.singh1 when i tried with actual data im getting the next line data as well. can u help me with this please?i just want vendor name from the below text is it possible to extract?

Received and reviewed, please process

Program Name: Falls Lake - JSA
Vendor Name: McAngus Goudelock , LLC
Vendor Address 1: PO Box 964
Vendor Address 2: not specified
Vendor City: Test
Vendor State/Location: NC
Vendor Postal Code (ZIP): 28296-1234
Vendor Tax ID (FEIN): uu16548
Claim #: P10000
Claim Professional: Wanda
Final Invoice: No
Invoice #: 164119
Total To Pay: 1727.72

Hi Aswini,

Could you add word bound at the end and try as below.

Vendor Name\s*:\s*(.*)

Vendor Name – matches the literal text.

\s* – matches any optional whitespace.

: – matches the colon.

\s* – matches any optional whitespace after the colon.

(.*) – captures everything after that (the desired text).

Mark solution if its help :blush:

Hi @Aswini,

This is also working ‘Vendor Name\s*:\s*(.*)’ and @Saravanan_Samy your query is correct.

@Aswini both query is correct.

1 Like

This seems like working in regex editor but when it comes to UiPath not giving the desired output

Will Vendor Name always be at the start of a new line?
If that’s the case you could try adding a ^ before the expression:
^Vendor Name\s*:\s*(.*)\b

Hello @Aswini,

you can use this two Regex Query.

1.Vendor Name\s*:\s*(.*)$

2.Vendor Name\s*:\s*([^\r\n]*)

Check and confirm once done.

Hello @sagar.singh1

Its working for me its giving me just Vendor name. Thanks for your help. However i am getting the result including the Field name as 'Vendor Name: McAngus Goudelock & Courie, LLC ’

Hello @Aswini,

You are getting the result including the Field name as 'Vendor Name: McAngus Goudelock & Courie, LLC ’

Because you are using Regex Builder activity if you are using assign activity then my query is give the output only ’ McAngus Goudelock & Courie, LLC ’ .

If you are free then schedule a meeting i will fixe.

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