Add counter to initial part of email address

Hi everyone,

I have a case,

I am checking if email exist in AD, then i have to increase/add a number at the end data before @. or if having a number at the end. increase it by 1. =>
Shekhar1@xyz =>

Hi @ShekharRPA ,

We should be able to Get the Existing Number in the Email with the Below Regex :


We could then use the below Expression to get the Number Value and assign it to an String variable:

str_No = System.Text.RegularExpressions.Regex.Match("","(?!=@)\d+",RegexOptions.IgnoreCase).Value.ToString.Trim

we could then increment this value, and then Convert it to String :

str_No = (Cint(str_No)+1).ToString

Next, we could use Regex Replace, to replace the 1 with the Updated value 2 :

System.Text.RegularExpressions.Regex.Replace("", "(?!=@)\d+", str_No)
1 Like

for first regex,
Getting this as an output. ??

@ShekharRPA , Could you Show me the Expression used ?

I believe you have not used the full Expression.

i have used full email address.
for second expression. the error is

Can you share me a xaml for better understanding and no confusion

@ShekharRPA ,
Check the Below Workflow :
Regex_ExtractNumber.xaml (6.3 KB)

Hi @ShekharRPA ,

Here is another solution →


IncrementIfDigitFound_v1.xaml (6.3 KB)

Kind Regards,
Ashwin A.K

it fail for those case where email does not have number

@ShekharRPA ,

Could you give the below Workflow a Try :
Regex_ExtractNumber.xaml (7.8 KB)

1 Like

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