Replace capital letters with italics

I have a bot that is filling some information into a website from an excel sheet.
If I have some text like: D-sometext-1-17B. D could be any capital letter while the number 17 could be any number. I want to change D to italics and also change the number 17 to superscript. So, I want an output like image
Please, I need help on how to achieve this.


Can we have some clarification on how this could be done manually so that we can provide the complete set of activities to perform this in UiPath


Hi @Palaniyappan
The website has some word editing functions, so, I usually do it like I would do when editing a word document.
Input test: D-Sometext-1-17B

  1. I will paste the text from excel to the web field
  2. I will highlight any capital letter that is standing alone and press ctrl + i to change it to italics.
  3. I will also highlight any number that preceeds a capital letter and change it to superscript.
  4. I will highlight any number after a capital letter and change it to subscript.

Actually, everything works like editing on a word document.

Hi @Palaniyappan,
Is my explanation clear enough or do I need to provide more information so that you can help me? The questions that I have basically are:

  1. What expression (maybe regex) can I use to identify a capital letter that is followed by a dash (eg A-) in my string?
  2. What expression can I use to some letters into italics within a string?
  3. How can I change some parts of my string to subscript or superscript?

Looking for any help or lead on these questions, please.

Not sure if there is an actual line of code that can complete this but you can essentially follow the same route your doing now, but you can build out a small sequence to achieve this…

Get the length of the text. (D-sometext-1-17B)
Click before the first letter, use hotkey “Shift & Right Arrow”.
Hotkey “Ctrl & I” (italics)
Hotkey “Right arrow” (deselects text)
Use a loop to highlight the remaining text, use hotkey “Shift & Right Arrow” (stop loop once last char has been highlighted, use a counter while looping)
Hotkey “Ctrl & +” (subscript)
Hotkey “Right arrow” (deselects text)

hi @Emmy_O

Please try with attached xaml Text.xaml (12.1 KB)

Need to set HTML for the formatting
You have to change the target element of click(text area) and send hot key (ctrl+v) activities.

Thank you so much @aanandsanraj. This is very helpful.
For my use case, the capital letter or number can be in varying positions. So, I will try to apply the same for other cases.

You are Welcome @Emmy_O