I have a string “me@gmail.com, you@yahoo.com, they@microsoft.com” and I want to remove anything that ends in “yahoo.com” from the string. So the result should be “me@gmail.com, the@microsoft.com”. I’ve tried the replace method but it doesn’t look like I can use wildcards in the match string. Is there a way to remove the “*.yahoo.com” email from the string?
Hello @rleonen , Welcome to the forums.
Please look up Regex Match and replace. You can use a regular expression to find all matches in a string and then replace them with blanks or remove them.
Here is a typical expression based on your Example:
A slight modification will help filter out more than one domain in the list:
I had posted a similar response on how to use Regex.Match in this post where we had to separate bullets from a bulleted text string.
I hope this helps.
Hey @rleonen
Welcome to the UiPath Community Forums
Are you using UiPath Studio? If so, see below.
To use a regex.replace use an Assign Activity like this:
Str_Variable = System.Text.RegularExpressions.Regex.Replace(INSERT_INPUT_STRING, “INSERT_REGEXPATTERN”, “REPLACE_WITH_THIS”)
To replace with nothing use two quotes (“”) in the last element.
If you are using Studio then I have made a workflow for your review but slightly different to what you have asked.
I have done something a bit different than what you have asked. I have used a regex pattern to match everything but the domains you want to keep “Gmail.com” and “Microsoft.com” and then replace it with nothing. You can preview the Regex pattern here.
Check out the workflow I have made. Below is the Output pane.
Main.xaml (5.5 KB)
Hopefully all this helps you