Add characters to the string

Hi everyone,

I have a string : “123,456,678(A),222,333(B),555,666(C),888,999”
Condition: If the final number is not (), the default is to add (A)

I do not know how to handle the results as follows: “123(A),456(A),678(A),222(B),333(B),555(C),666(C),888(A),999(A)”

Thank!

HI @longnt23,

Split the string using “,”

For loop it Add the value (A) in end

then combine the string using string.join(“,”,yourarray value)

Regards, Arivu :slight_smile:

Thank @arivu96!
But in string: “123(A),456(A),678(A),222(B),333(B),555©,666©,888(A),999(A)” have (B) and ( C). And desired results: “123(A),456(A),678(A),222(B),333(B),555( C),666( C),888(A),999(A)”.

Thank!

Hi @longnt23,

I think you can use regex and for loop to check after you split them using “,”
so… if the last character is digit, do the string.join
There is this activity called Matches and the the regex should be \d

hope it helps!

Warm regards,
Lavina