Extract OTP Using Regex or Any other, Activities

****** - Action Required: One-time verification code
Hi User,
You are receiving this email because a request was made for a one-time code that can be used for authentication.

Please enter the following code for verification:

543216

If you believe you have received this email in error, please reach out to your system administrator.

In this above text i need to extract only OTP number
Can you give me regex for this.

Hi @Vicky_K ,

If the format is same always, then it is observed that the value is a number and there are no such other areas where a number is observed. Hence, maybe we can shorten the regex to the below :

\d+

image

Let us know if there are differing formats.

Hi @Vicky_K

give a try with

Regex.Match(inputString, "\d{6}", Text.RegularExpressions.RegexOptions.Multiline).Value

image

Regards

1 Like

Thanks but i received this above text by mail
so mail have subjects and as well date so i tried "\d(6) already it goes to date so can you give me to get only OTP with start and ends with??

@Vicky_K ,

If that is the case, then we can make it more specific to what you need. Check the below regex expression :

(?<=Please enter the following code for verification:)(.*\n)*\d+\b

Expression :

System.Text.RegularExpressions.Regex.Match(yourInputVar,"(?<=Please enter the following code for verification:)(.*\n)*\d+\b").Value.Trim

Let us know if you are not able to get the required output.

1 Like

Thanks…

Thanks,
Its working Fine now

1 Like

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