I am trying to separate the UserName field by Space so I can return only the First Name
What should I input in the Separator field of the Text split object ?
Apparently it does not let me put a simple space
Thank you
I am trying to separate the UserName field by Space so I can return only the First Name
What should I input in the Separator field of the Text split object ?
Apparently it does not let me put a simple space
Thank you
Hi there,
You would first of all need to use the replace method to replace the space with a character that can be used with the split method. Perhaps a colon or other character that you wouldn’t expect to find in the text.
Then you can use the split method to split the text based on this character.
Alternatively, if you know a little Node.js you can use our Code service for a more refined solution.
Thank you very much for your answer
Can you tell me how to specify Space in the Replacement field ? it does not seem to work directly as as a ’ ’
You just press the space bar. I know the interface highlights red as though there is an issue but it will actually let you save the task.
Sorry to bother … but the Next button is gray (cannot be pushed) and I get a red Required sign. No possibility to save if I just input Space on the left Key Replacement field.
Thanks again
Sorry about that. I’ve done something similar in the past but perhaps I was mistaken about using just a simple space.
Let me share a more refined approach with you so that you can get this sorted.
If you add in a Code service task to your Flow and in the Inputs section add an input called name on the left side and insert the username output of your Bot message on the right side.
In the code box, use the below. This will separate the text and output the first value (first name).
var res = inputs.name.split(" ");
resolve(res[0]);
It should end up looking like this:
Hi guys,
I am also having the same problem.
I am receiving a string “MY ACCOUNT 4456” and i would like to break the STRING into 3:
I have tried putting a space as a separator in order to use the “space” as the separator of the 3 words but i cannot.
Can you help?
I know it’s annoying (we’ll get split by space sorted soon)!
In the meantime, use the code service like this:
So use the code:
resolve(inputs.input.split(" "));
Instead of {{receive_a_webhook.input}}
in input
that you see in the screenshot, you need to use the output there that contains the text you want to split.
In your next action, to use each of the words, you need to add __0
, __1
, __2
at the end of the output, for example {{code_execute_code.result__0}}
(first word), {{code_execute_code.result__1}}
(second word) etc…
Hope that helps!