How to capture specific sales number from email text?

Dear Experts

Previously I can use below Regular Expression to capture the sales number(伝票番号) from email text

System.Text.RegularExpressions.Regex.Match(mail.Body.ToString,“(?<=伝票番号\D+)[\d,]+”).value

image

But now business changes and we will have another sales number(伝票番号) form which start with “G” plus 9 number

image

However, the above Regular Expression can only capture 9 number(900002875) under this scenario

May I know how to modify the current Regular Expression to capture both 10 number form(4646160055) and “G”+ 9 number form(G900002875)?

Thank you for your help in advance

1 Like

Hi,

How about the following expression?

System.Text.RegularExpressions.Regex.Match(mail.Body.ToString,"(?<=伝票番号\s+[::]\s+)\w+").Value

Regards,

@Yoichi

Thanks for the quick feedback. I try just now but it capture nothing as result

image

And below is more detail for your reference

Thanks

HI,

Can you share your string as file if possible?

Or can you try the following?

image

System.Text.RegularExpressions.Regex.Match(mail.Body.ToString,"(?<=伝票番号\W)\w+").Value

Regards,

@Yoichi

I try with the following RE but still not working. Same result as above

System.Text.RegularExpressions.Regex.Match(mail.Body.ToString,“(?<=伝票番号\W)\w+”).Value

Pls check the xaml file in the attachment
JACCS.xaml (25.6 KB)
JACCS.xaml.json (142 字节)

And below is the email form for your reference
image

Thanks

Hi,

First, can you set BreakPoint at the following point. Next, debug run, and workflow will stop there, then check content of currentSO at Locals panel?

If currentSo is empty, can you share text of mail body as file if possible? (WriteTextFile activity will help you)

Regards,

@Yoichi

Test as you advise and its still empty
Pls check the email text in the attachment for your reference

image

Email Content.txt (1001 字节)

Thanks

HI,

It’s my bad.(Missing + sign) Can you try the following expression?

System.Text.RegularExpressions.Regex.Match(mail.Body.ToString,"(?<=伝票番号\W+)\w+").Value

Regards,

1 Like

@Yoichi Thank you for the patience. It should be ok now. There is another run in 3 hours. I will click solution closed if nothing wrong after that

Thank you again :laughing:

image

1 Like

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