Skip to main content
Community site session details
Power Automate - Building Flows
Answered

Extracting name from email subject line

Like (1) ShareShare
ReportReport
Posted on 18 Sep 2023 15:49:47 by 326

Hi there, 

 

I am trying to extract a name from an email subject line. I have got as far as splitting something... but took off the first letter rather than the whole word. Please help!

 

The subject line is as follows:

Word Word Word Word FIRSTNAME LASTNAME number

 

I need the first name and last name (i.e. the 5th and 6th words put together). What's the best way to use an expression to get this?

 

Additionally, further down my flow I need to make sure that a flow doesn't trigger a second time if there are replies to an email (so RE or FW at the start). Is there a way to add a trigger condition or do something else so that this doesn't happen? Otherwise I am going to have duplicate rows.

 

Thank you 🙂

  • trice602 Profile Picture
    14,120 Super User 2025 Season 2 on 25 Sep 2023 at 14:54:08
    Re: Extracting name from email subject line

    Nice!  Have a great week! 

  • cb23 Profile Picture
    326 on 25 Sep 2023 at 09:11:20
    Re: Extracting name from email subject line

    Perfect! Thanks so much @trice602 cb23_1-1695633056284.png

     

  • Verified answer
    trice602 Profile Picture
    14,120 Super User 2025 Season 2 on 22 Sep 2023 at 23:09:49
    Re: Extracting name from email subject line

    Hi @cb23 ,

     

    I just tested this in a sample flow and it does identify the replies and forwards.  Please mark this reply as a solution too!  

     

    trice602_0-1695424172329.png

     

  • cb23 Profile Picture
    326 on 21 Sep 2023 at 15:26:58
    Re: Extracting name from email subject line

    Hi @trice602, just to follow this up - do you have any advice on the RE/FW element I mentioned? Thanks.

  • cb23 Profile Picture
    326 on 18 Sep 2023 at 17:10:28
    Re: Extracting name from email subject line

    Hello @rzaneti , thank you so much for your detailed reply. The explanation is much appreciated. I tried @trice602's expression and this worked even though it is slightly different to what you recommended. Are there any differences in the approach that I should know about that are potential pros or cons? Thanks again.

     

    I will check the RE/FW docs you shared tomorrow (I'm now finished work for the day!) 🙂 

  • cb23 Profile Picture
    326 on 18 Sep 2023 at 17:08:15
    Re: Extracting name from email subject line

    Thanks so much Tom. That has worked!

  • rzaneti Profile Picture
    4,096 Super User 2025 Season 2 on 18 Sep 2023 at 16:02:49
    Re: Extracting name from email subject line

    Hi @cb23 ,

     

    Assuming that the first and last names will always be the 5th and 6th words into the Subject Line, you can use this flow design:

    rzaneti_1-1695052517797.png

     

    Note: the variable 'text' is simulating your subject line. When applying this approach in your end, you don't need to create this first variable.

     

    Expressions used

    Variable 'array' expression: skip(split(variables('text')' '), 4) - make sure to replace the text in red for the dynamic content of your subject line.

     

    Variable 'name' expressions: variables('array')[0] and variables('array')[1] - make sure to replace the variables('array' for the dynamic content of your 'array' variable, generated from the subject line.

     

    Quick explanation about what is happening

    We are first transforming your subject line into an array, by using the split expression. As we are using a blank space as separator, each word will be an array element. As we know that we will be using only the 5th and the 6th element, we are applying a skip method, to ignore the first 4 elements from the generated array. So the final output from 'array' variable will be the following:
    rzaneti_2-1695052802550.png

     

    In 'name' variable, we are accessing the first and the second elements from the array. We use [0] to access its first element, and [1] to access its second one. It happens because the arrays in Power Automate are 'zero-indexed', so the count starts in zero, and not in 1.
     
    If this first approach works for you, we can move forward and work into the filter for the RE/FW!
     
    Also, I recommend you these 2 articles that I recently wrote about text mining in Power Automate and working with arrays in Power Automate:
     

    Let me know if it works for you or if you need any additional help!

     

    -------------------------------------------------------------------------
    If this is the answer for your question, please mark the post as Solved.
    If this answer helps you in any way, please give it a like.

    http://digitalmill.net/ 

     

     

     

     

     

     

     

  • Verified answer
    trice602 Profile Picture
    14,120 Super User 2025 Season 2 on 18 Sep 2023 at 15:57:21
    Re: Extracting name from email subject line

    Hi @cb23 ,

     

    Here's the expression to dynamically get your first and last.  Please mark as a solution and we can look at your second question.

     

    trice602_1-1695052673823.png

     

     

    slice(variables('Subject'), add(nthIndexOf(variables('Subject'), ' ', 4), 1), nthIndexOf(variables('Subject'), ' ', 6))

     

    trice602_0-1695052625967.png

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Tomac Profile Picture

Tomac 986 Moderator

#2
stampcoin Profile Picture

stampcoin 699 Super User 2025 Season 2

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 577 Super User 2025 Season 2

Loading complete