Search code examples
blueprism

BluePrism count number of times a character exists in a string


I have a calculation which will remove a blank space and replace with a full stop. This is correct for 90% of my cases. However, sometimes two blanks will appear in my value. For the second space I want to delete it. Is this possible? I think it may be possible using a code stage, but I am not sure what the code would be.

My current calculation is Replace([Item Data.Name], " ", ".")

Example data John B Smith I want the result to be John.BSmith


Solution

  • I resolved this issue by using the Utility - Strings object and the split text action. I split my name by space. This outputted a collection which I was then able to loop through and add a full stop after the fist instance but then trim the other instances.

    Please see screenshot

    enter image description here