cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kyza
Helper II
Helper II

Extract piece of string from Email Subject

Hello ,

I am kinda lost in flow expressions.

I would need to extract a number as a string from email subject which flow catches.

The thing is that I cannot hardcode the index of the number length as it may differ.

Is there any way I could extract all numbers after "EMID:" within the string all the way to the space followed after numbers?

Example:  "some random text EMID:12345 some random text"

Desired result: "12345"

 

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
v-bacao-msft
Community Support
Community Support

 

Hi @Kyza ,

 

Please try to refer to the methods provided by @edgonzales  to achieve your needs. As a supplement, it is recommended to use "EMID:" as a split point.

Image reference:

20.PNG

Expression reference:

trim(split(split(triggerBody()?['subject'],'EMID:')[1],' ')[0])

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
edgonzales
Super User II
Super User II

@Kyza 

Hi there!  Check out the Split function, it's pretty cool.  It splits a string on a delimiter of your choosing, and converts it to a table/array.

In your example, you could split on the colon and then grab the second element.  The expression might look something like this:

split(triggerBody()['text'],':')[1]  (the [1] is the part that grabs the stuff on the latter half of the colon.
 
But now, you want to lose everything after the first space, right?  So do another split on the space and take the first element ([0]).  You can either do this in a subsequent step, or nest it with the original split:
split(split(triggerBody()['text'],':')[1],' ')[0]  (the [0] is grabbing the first element of this new array)
 
Now, if you know that the result will always be a number, you can wrap all that in an Int() to convert it from an 'array' to an integer:
int(split(split(triggerBody()['text'],':')[1],' ')[0])
 
Keep us posted.
-Ed-
 

If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

 
v-bacao-msft
Community Support
Community Support

 

Hi @Kyza ,

 

Please try to refer to the methods provided by @edgonzales  to achieve your needs. As a supplement, it is recommended to use "EMID:" as a split point.

Image reference:

20.PNG

Expression reference:

trim(split(split(triggerBody()?['subject'],'EMID:')[1],' ')[0])

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Thank you so much 🙂 Sorry for late response, I had different stuff to work on recently.

Helpful resources

Announcements
MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (45,692)