Hello, i have an automation problem
so I have a several product name which I want the robot to remove the last word in the product name (after space)
Reinforced Steel Bar
i want to delete the last word (“bar”) so it will become “Reinforced Steel”
i want to delete the last word (“(new)”) so it will become “Mirror”
So how can i achieve this?
Thank you in advance
Can you try the following expression?
Hi @Fauzan_Marantama ,
Besides @Yoichi’s regex solution, another possible way to solve the issue would be:
stringVariable.Replace(" "&stringVariable.Split(" "c).Last,"")
This is the correct solution. So many people try to overcomplicate things with Regex and complicated expressions. Simple works.
which is the correct solution?
Like @jakub.brzezinski wrote, the correct solution that @postwick refers to is:
YourString is literally the Variable that you created to store the string.
If you created a Variable called Badget and you Assigned your BadgetName to it
Badget = Robot Apprentice
You create a variable with type string to store the result, lets say the cariable that you create is called OutBadget
when you use the formula
OutBadget = Left(Badget.Trim,yourString.Trim.LastIndexOf(" "))
Know the value inside OutBadget will be only “Robot”