Return 1st word of a string

Hi Community!

Here’s with a somewhat easy request, though, not being successful yet. I need to return a text from a string, which has 2 possibilities:

  • If input string contains only 1 word, return “No project ID”
  • If input string contains more than 1 word, return the 1st word of the string

Any idea how to do it? Im trying directly from the functions available (split, contain, etc.) yet not being able to do.

Appreciated the help!

1 Like

Hey there,

what does the string look like?
Here is a function that will do that if its text separated by spaces:

{{if(length(split(1.test; space)) = 1; "No project ID"; get(split(1.test; space); 1))}}

Thanks Stoyan for the reply!

I tried and unfrotunately, it doesnt work. So to give more details, the input text is the subject of an email, which always contains either 1 or 2 words. For some reason, your proposal returns always the 2 words.

What Ive managed to get working is to get just the 1st word with:

{{first(split(125.Project_Name; space))}}

However, Im not able to take it to the next level, which it is returning “No project ID”, when only 1 word. Any thoughts?

Thanks!

1 Like

Can you show examples of the subject? Ideally ones that failed.

sure thing. Subject of just 2 words. Examples:

Velez material
Velez alimentacion
Maaji viajes

1 Like

I tested with all 3 and its returning only the first word. Can you share some screenshots of how you have it setup and how it ran?

Here you go. The field “24.Subject” refers to the subject captured from initial webhook

1 Like

Hi @Arjonj03


You can try this method.

{{if(length(split(1116.string; space)) = 1; "No project ID"; first(split(1116.string; space)))}}

Best regards,
Msquare Automation
Platinum Partner of Make
@Msquare_Automation

1 Like

And what are the inputs and outputs of the module?

Mate that’s exactly the same as I posted except it uses first() instead of get()

Yes. and it is not working. I only managed to get working to capture 1st word with this screenshot, yet, it doesnt cover for “No project ID” option.

1 Like

This one worked. THANK YOU!

2 Likes

Hi @Arjonj03

Glad to know it worked for you.

Best regards,
Msquare Automation
Platinum Partner of Make
@Msquare_Automation