Q:

Extracting the name of the file until the first space into a new column

I am trying to create a automated flow which will copy the file name into a new column up until the first space in the name. For example:
The uploaded file name is **ZKAL12345-I RTR 123ml Product Label Region 61.PDF so i would like the column to be name ZKAL12345-I
I've found the below code, which works well, however, it stops the naming at the dash (-) and as i am sure you can still im not quite sure how to change it to the requirement above .
substring(triggerBody()?['{Name}'], 0, lastIndexOf(triggerBody()?['{Name}'],'-'))

Any help is appreciated.
Many thanks,
Artur

A:

Could you not just do
substring(triggerBody()?['{Name}'], 0, indexOf(triggerBody()?['{Name}'],' '))

?
indexOf() returns the first index of the searched for value, in this case, a single space, which in your case would be the space between "ZKAL12345-I" and "RTR".

