How to extract uncertian length field with substring?

Dear Friends

I want to extract the number as below highlighted from a bunch of same format emails. However, the number length varies from emails to emails

May I know how to make it happen with [substring]?

PS: “円” must be excluded from the result

image

Thanks
Ivan

Hi @yangyq10

Assign -> Input = "現金価格合計(税込): 208,044円
                   申込金(頭金) :0円
                   残金 : 208,044円
                   分割払手数料 :0円
                   分割支払金合計 : 208,044円
                   お支払総額 : 208,044 円"

Assign -> Output = System.Text.RegularExpressions.Regex.Match(Input,"(?<=お支払総額\s+\:\s+).*(?=\s円)").Value.trim()

Regards

Hi,

Can you try the following expression?

System.Text.RegularExpressions.Regex.Match(yourString,"(?<=お支払総額\D+)[\d,]+").Value

regards,

Dear Varunraj

Thanks for the prompt reply

May I know how to set ariable for the whole part from 現金価格合計(税込):208,044円 to お支払総額 :208,044円 so that I can use them in the regular expression?

The reason I ask this is that I have 10 to 20 same format emails which I need to extract the different [お支払総額] and wirte in excel.

image

image

Dear Yoichi

Thanks for the prompt reply

May I know how to set variable for the email body?

I have 10 to 20 same format emails which I need to extract [お支払総額] from them and input into excel

image

image

Hi @yangyq10

Use Build Data Table Activity and create a column Amount like below


Do this after Get Outlook Mail Messages.

After extracting that you can use Add Data Row activity
image

Outside the For Each loop use Write Range Workbook to write dt_Output to an excel.

Regards

Thanks for the reply

I try put mail.body.Tostring to replace the whole email text but nothing show up while debug
Do you know which part I may go wrong?


It works just now!!


image

1 Like

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