If a string contains text as per below example need to replace this string text with some variable value…
Eg: Action Needed-<< Email Subject>>
How to replace this Email Subject string with Variable value…
Var1= “Uipath”
Needed suggestions…
If a string contains text as per below example need to replace this string text with some variable value…
Eg: Action Needed-<< Email Subject>>
How to replace this Email Subject string with Variable value…
Var1= “Uipath”
Needed suggestions…
give a try on regex when we have to find the Email Subject within a string and it is dynamic
(?<=<<).*?(?=>>)
Assign Activity
Left: myNewString
Right:
System.Text.RegularExpressions.Regex.Replace(myOriginStringVar,"(?<=<<).*?(?=>>)",Var1)
When we do create a string with such a pattern we can do:
Assign Activity
Left: myNewString
Right:
String.Format("Action Needed - << {0} >>"),Var1)
or very simple: "Action Needed - << " & Var1 & " >>"
When working with Placeholder for replacements we can do
Assign Activity
Left: myNewString
Right:
"Action Needed - << #ES# >>".Replace("#ES#",Var1)
You mean that you are storing this subject in a variable and you need to replace some part with the variable
Can you share me correct format you are looking for?
You can use Replace or Regex if there is any format
Hope this may help you
Thanks
Hi
It’s as simple as using string format
Say for example you have the input string like this
Strinput = “Action Needed-<<{0}>>”
And you have a variable named Var1 with text in it
Then use this expression in a ASSIGN activity like this
Stroutput = String.Format(Strinput,Var1.ToString)
{0} is the place holder where that value.ToString will get replaced
Or you can use a simple REPLACE method of ToString
Like this
Stroutput = Strinput.ToString.Replace(“<< Email Subject>>”,Var1.ToString)
Hope this would help you resolve this
Cheers @suryasuhas527
You can try with
Str_Variable=Your mail variable.Subject.Replace(“old str”,“New Str”)
Regards
Sudharsan
Hello @suryasuhas527
Are you trying to make the subject dynamic by replacing the variable value?
Or simply you can append the variable to the string
Var1= “UiPath”
Subject = “Action Needed-<< “+Var1+” >>”
If any other questions then let us know.
Mark as solution and like it if this helps you
Happy Automation
Best Regards
Er Pratik Wavhal