Remove and Replace

hi RPA wizards! Please help.

I need to replace the word “TBD6” to the corresponding Service ID, I have an idea of using Replace, but I don’t know how to figure it out. Thanks :slightly_smiling_face:

Example Message :
“You’re now registered to TESTRPA1. <ABCD_EFGH_IJKLM_MB_TBD6>.”

Upon getting the equivalent service id of TBD6(which is 6666), the new message will be:
“You’re now registered to TESTRPA1. <ABCD_EFGH_IJKLM_MB_6666>.”

image

Convert datatable to string using output datatable activity and apply following expression.

System.text.regularexpression.regex.replace(YOUR MESSAGE,“TBD6”,“666”)

Hi @rahatadi, on this case, i don’t know what TBD# that user going to input. This is my workflow but i can’t remove the # in “TBD”

image

Message: “You’re now registered to TESTRPA1. <JNETXT_WALLET_AMOUNT_MB_TBD6>.”

Result in output: You’re now registered to TESTRPA1. <JNETXT_WALLET_AMOUNT_MB_66666>.

correct result should be : You’re now registered to TESTRPA1. <JNETXT_WALLET_AMOUNT_MB_6666>.

@Juliene,

Have created a workflow based on your requirement.

Please find the same.

Replace.zip (18.8 KB)

@Juliene

Use Read range activity into dtTable

For each row in dtTable
If (row(“Data Service ID”).tostring.contains(“TBD6”))

Replace(“TBD6”,“Newword”)

Hi,

This is also useful but in my case, I don’t know what TBD number user will input. Is there any way to make it wildcard? how?

what you can do is to use an input dialog to request the user to key in a value, store it as a string lets say variable1 and the in lookup value change “TBD6” to “TBD” + variable1. this should help u look up different values but do remember to set a flow decision to ensure no one keys outside of the expected value range.

Unfortunately, I’m not allowed to use input dialog box to ask the user.
Here’s my replace code. Could you please check.

image

Message.Replace(“TBD”,str_outputSID). I tried to use Message.Replace(“TBD” + “*”,str_outputSID), but it’s not working.

@Juliene,

Please find this and give the user input as “You’re now registered to TESTRPA1. <ABCD_EFGH_IJKLM_MB_TBD6>” this format.

Regards,
Mohanraj.SReplace.zip (19.1 KB)

wildcards only applies to selectors if i’m not wrong, i don’t think there is a way unless u prompt the user to key in the value since you don’t know what values they will key in

or there is another way of setting a cell exclusively in excel or whichever value the user selects then use recording to retrieve the value

You can use regex replace instead of string replace to match a pattern - then you can match “TBD” followed by a single number.
To use regex replace you need to import the System.Text.RegularExpressions library in the imports tab of the workflow.
It would look like:
yourNewString = Regex.Replace(yourInputString, “TBD[0-9]{1}”, yourReplacementString)
The pattern says - match the characters TBD exactly, then match a single character which is between 0 and 9.

Have a look at RegExr to see how different patterns impact the result, and for a pattern cheat sheet - for example, if you use “TBD[0-9]{1}$” instead, it will only match the pattern if it’s at the end of the string.