Let's POWER Automate

From no-code to low-code

Menu
  • Expressions
  • Filters
  • General
  • Triggers
  • Application specific solutions
    • Dataverse
    • Excel
    • Forms
    • Planner
    • Outlook
    • SharePoint
    • Teams
  • Resources
  • Get help with flow
Menu

How to split string by the first space in Power Automate

Posted on December 15, 2021December 19, 2021 by Tom

“I have a string where the actual data starts after an id number and a space, how can I split it by the first space and process only the data with Power Automate?”


When you split strings in Power Automate, you can use the expression split(…). You enter the string to split, the separator, and you’ll get back an array with all the pieces. It’s a solution described in one of the previous posts. But what if it’s not that simple? If you don’t want to split the whole string, but split just a part of it? Only at the first occurrence of the separator, and keep the rest untouched?

Split(…) the string anyway

You still want to start with the split(…) expression. Take the whole string and split it. The reason is that even though it’ll split it into multiple pieces, it’ll create an array. And it’s much easier to work with an array. Let’s take an example and split the string by a space.

split(<string to split>, <separator>)

As you can see, the result is an array with each part of the string as a separate item.

Skip(…) the part before the first space

Once you have an array, it’s easy to ignore a piece of it, much easier than to ignore a part of a string. Power Automate has an expression skip(…) exactly for that. The skip(…) expression expects an array and a number of items it should skip.

skip(<array>, <number of items to skip>)

To skip the first item in the array, use the number 1. Extending the expression from above:

skip(split(outputs('Compose'), ' '), 1)

Join(…) the array back into a string

Now, when you removed the undesired item, you can take all the remaining items and turn the array back into a string. With the join(…) expression take the array, define the delimiter, and turn it into a string. It’s the reverse process from the split(…) in the first step, therefore, you should use the same separator.

join(<array>, '<delimiter>')

Following the example in this post, it might look like:

join(skip(split(outputs('Compose'), ' '), 1), ' ')
Power Automate split string first space

The result is the original string without the part before the first space.

Power Automate split string first space

Summary

Power Automate expressions make it easy to split a string by the first space, if you convert it to an array first. It’s much easier to work with, so don’t be afraid to use it. You can navigate an array, skip or take part of it, and when you’re done, you can easily convert it back to a string. You don’t care about the string length, or how long is the part to skip, all the things you’d have to do if you kept it as a string…


Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Do you know what to do, but not how to do it?

Get The Ultimate Power Automate expressions cheat sheet and translate your thoughts into flows with ease!


NEW! Master the HTTP requests to SharePoint with a new cheat sheet!

Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

Hello and welcome!

My name is Tom and I'm a business process automation consultant and Microsoft MVP living in the Czech Republic. I’ve been working with Microsoft technologies for almost 10 years, currently using mainly Power Automate, SharePoint, Teams, and the other M365 tools.

I believe that everyone can automate part of their work with the Power Automate platform. You can achieve a lot by "clicking" the flows in the designer, but you can achieve much more if you add a bit of coding knowledge. And that's what this blog is about.

To make the step from no-code Power Automate flows to low-code flows: using basic coding knowledge to build more complex yet more efficient flows to automate more of your daily tasks.

  • Use Power Automate to forward Outlook events upon registrationJanuary 29, 2023
  • Why the condition is false for the same numbers (Power Automate)January 25, 2023
  • How to forward event invitation to other calendar (Power Automate)January 22, 2023
  • Run ‘For selected item’ flow from non-default environment (Power Automate)January 18, 2023
  • Hide button in SharePoint list after Power Automate flow startedJanuary 15, 2023

Power Automate blogs worth visiting

Damien Bird
Dennis (Expiscornovus)
Paul Murana

©2023 Let's POWER Automate | Theme by SuperbThemes