Return the first word in a string

I would like to use the JavaScript Transform to create a new column that contains the first word of an existing column.

What is the JavaScript to do so?

I didn’t see an example in the JavaScript Help documentation.

Perhaps the Extract Transform could contain some basic selectable arguments such as return First Word, First # words, Last word, Last # words.


To turn this:




It is probably simplest to use Replace with a regex.


NB/ You can also use regex inside a Javascript transform.

Why not use the Split transform with a delimiter of space with min and max of 1? I know you asked for JavaScript but if I understand the problem correctly this would be a
very simple solution.


Good call @Vann . That is simpler than a regex.

That worked brilliantly.


1 Like