Here is an example that should help.
In my test, I am getting the display name from a variable called varDisplayName.
substring(variables('varDisplayName'),0,indexOf(variables('varDisplayName'),' '))
I an using the substring() expression - I am saying that I want part of a string and I want to start at position 0.
I am also saying that I want a certain number of characters - I am looking for the first space and retrieving the position of that space using the indexof() expression. The position of that space is the number of characters I want.
If you need additional help, please post here.
If this solves your issue, please mark your question as Solved.
Scott