Regular Expression content forces "Apply to each" step

I'm using Power Automate with Regular Expression Match.

My trigger is when an email arrives in a specific outlook folder. So, that returns only one email on each trigger. I am RegEx matching against the subject (and later the body).

I ask because whenever I select dynamic content from the match (in later steps) power automate forces an "Apply to Each" step.

Is the Regular Expression Match returning a set and not just a single record?

Can I stop that? It's not a huge problem. Just an annoyance because I have to work with "Apply to each" when I only have one "each". It clutters up my flow.

Thanks.

Hello @Paul,

Regular Expression Match action returns an array of Matches (Match0 Match1, etc). For example, if you select dynamic content Matches - Flow automatically select Apply to Each action, since it's an array.

Best Regards,
Petr Bushuev
Plumsail team

Thanks @Petr,
When you say "...if you select dynamic content Matches..." is this a selection that I make within Plumsail's Regular Expression Match step? If so, I'd like to turn that off so I don't get an array. I only need one result since I'm only passing one record.

Or is returning an array the unchangeable default of the step? If so, are there RegEx steps that only return 1 result?

Thanks again for responding.

Hello @Paul,

If you need only 1 value (not the array) you can select dynamic content Match0, Match1, etc. In that case, the Apply to each action will not be created.

Best Regards,
Petr Bushuev
Plumsaiul team

Hmm. That seems like it might help. However when I change Matches to Match0 in my Apply to Each it forces another encapsulating Apply to Each with a Matches.

Thanks.

Still no resolution here.
Any help would be appreciated.

Hi @Paul,

It means that the resulting JSON has several Match0 values, For example

[
{
"Match0": "Task 5:Approve",
"TaskId": "5",
"status": "Approve"
},
{
"Match0": "Task 53:Reject",
"TaskId": "53",
"status": "Reject"
},
{
"Match0": "Task 52:Approve",
"TaskId": "52",
"status": "Approve"
}
]

This is a result of our example:

image

So, the dynamic response based on a pattern that is used in this action. Contains all matches groups that included in the pattern (named or unnamed).

So, the Apply to each option is expected if there are several matches.

Best Regards,
Petr Bushuev
Plumsail team