How to add a number that contains string and numbers. for example ABCD1234 and i want to add +1 to end like ABCD1235

i am using get text to get ABCD1234 and im storing in variable like gettextvar and i want to add a single number at the end like ABCD1235 so may i know how to do this please?

Hi @sathish_Kumar6

You can try the following steps:

  1. Use the Match activity to check with regular expression and fetch the number value from your string as below:


Regex - [0-9]\d*(.[0-9]\d+)?

  1. This will return the matched numbers from your string as IEnumerable type.

  2. From the output you can take the first match which will be 1234

  3. In the Assign activity you can convert this to Integer and can add 1 to it.

Regards,
Rajeswari

could you ellobrate for like… by getting text var from get get text activity then passing it to regex… sorry i dont how to do this so could you please share xaml for this please…that would be really helpful. and thanks for the reply rajeshwari

@sathish_Kumar6 ,

Please try out this xaml
NumberFetchFromString.xaml (6.6 KB)

The string which is returned by Get Text activity have to be given as input to Matches activity

Regards,
Rajeswari

hi rajeshwari huge thanks for this effort… one last thing to ask… when i ran your xaml im getting values just only for numbers like 1235 for 1234 number but i want abcd1235 as string and number to be concatinated at end…sorry for asking too much im new to this…

1 Like

@sathish_Kumar6

Check this new xaml which will do the needful.

NumberFetchFromString_Revised.xaml (9.5 KB)

Regards,
Rajeswari

Hi,

FYI, the following expression will return what you expect (even if the number string starts with 0)

System.Text.RegularExpressions.Regex.Replace(yourString,"\d+",Function(m) (CInt(m.value)+1).ToString("D"+m.Value.Length.ToString()))

Regards,

thank you so much…it means lot to me… really very huge thanks rajeshwari…u saved me

2 Likes

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