How to add a character from right end?

Hi,

I am trying to add a comma “,” from the right end only after a capital letter.

Input: “First Lastname AGNP”

Expected output: “First Lastname, AGNP”

Any help will help, Thanks in advance.

@jai_kumar2

System.Text.RegularExpressions.Regex.Replace(DateToday,"[A-Z a-z]+\s[A-Z]+","[A-Z a-z]+\,\s[A-Z]+")


Multiple options, but here’s one:

Input = "First Lastname AGNP"
new_Input = Input.replace("Lastname", "Lastname" + ", ")

Hi @jai_kumar2

Try this:

inputString = "First Lastname AGNP"

outputString = inputString.Insert(inputString.LastIndexOf(" ") + 1, ",")

Hope it helps!!

Hi @rlgandu Thanks for the reply

This output add comma to every caps in the string like “First , Lastname , A, G, N, P”

But Expected output: “First Lastname, AGNP”

Hi @jai_kumar2

Check the below image for better understanding

Regards

No it doesn’t… :slight_smile:
image

Hi @Parvathy Thanks for the reply

I got the expected output.

Thank you.

1 Like

You’re welcome @jai_kumar2

Happy Automation!!

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