Bot has to take 2a3b4c as input and retrun aabbbcccc as output

Hello All,

i am new here and started explore the tool but came across small use case where bot has to take 2a3b4c as input and retrun aabbbcccc as output.

so, can you please suggest me the best way to do it.

thank you

Hi @learnrpa0910

Can you try this

Output = String.Concat(System.Text.RegularExpressions.Regex.Matches(Input,"(\d+)([a-zA-Z])").Cast(Of System.Text.RegularExpressions.Match).Select(Function(m) New String(m.Groups(2).Value(0),CInt(m.Groups(1).Value))))

Regards,

@lrtetala ,

great, its working.

but can we make more dynamic since input is expected to change dynamically(ex 3d2c5h7y or 3v6h7a ).

thank you

@learnrpa0910

It would work for all cases

Regards,

yes, its working, thank you

1 Like

FYI, another approach:

System.Text.RegularExpressions.Regex.Replace(strInput,"(\d+)(\D)",Function(m) New String(m.Groups(2).Value.ToCharArray.First ,Cint(m.Groups(1).Value)))

Hi @learnrpa0910

Use below exp:
Output = String.Concat(System.Text.RegularExpressions.Regex.Matches(Input, “(\d+)([a-zA-Z])”).Cast(Of System.Text.RegularExpressions.Match).Select(Function(m) New String(m.Groups(2).Value(0), CInt(m.Groups(1).Value))))

@learnrpa0910
Uipath_batch (3).zip (1.9 MB)

Use below zip file here you can get the soltion