web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Split text - capitalis...
Power Automate
Answered

Split text - capitalised phrase - split text with inbuilt conditions

(0) ShareShare
ReportReport
Posted on by 38

Hi all!

 

I am hoping someone can help me figure out this issue.  I want to be able to extract (split) text (event subject) that could look like any of the below: 

EXMAPLE 1: BLOGGS, Joe (Meeting - Office) 

EXMAPLE 2: BLOGGS, Joe, DOE, Jane (Meeting - Offsite)

EXMAPLE 3: SMITH, Timothy John, PHILLIP, Fairmont, GRACE Sally-Louise (Monthly Update - Richmond Office)

 

The results I ultimately want are:

function1: 

EXMAPLE 1: BLOGGS 

EXMAPLE 2: BLOGGS, DOE

EXMAPLE 3: SMITH, PHILLIP, GRACE 

function 2: 

EXMAPLE 1: Joe

EXMAPLE 2: Joe, Jane 

EXMAPLE 3: Timothy, Fairmont, Sally-Louise

 

I need the last name and first name in separate functions because they are used separately later on in the flow. 

 

Currently, I have a function that works for EXAMPLE 1 - 

Compose: split(triggerOutputs()?['body/subject'], ' ')[0]
which results in:    BLOGGS,
Compose: split(outputs('SURNAME_(with_comma)'), ',')[0]
which leaves me with:    BLOGGS
 
This works perfectly where there is only 1 name in the subject (as in EXAMPLE 1) .  However I can't figure out how to extract this if there is more than 1 name.
 
Ultimately my question is - is there a way to extract only the ENTIRELY capitalized words? and/or is there a way to extract the first word immediately after a comma (even where there are multiple commas, like in EXAMPLES 2 and 3) ? 
Categories:
I have the same question (0)
  • Verified answer
    SamLed Profile Picture
    2,340 Moderator on at

    Hi @StillLearning_,

     

    Here's a working method:

     

    SamLed_0-1707904769444.png

     

    From expression: split(replace(outputs('Compose'), ',',''), ' ')

     

    Note: It replace any comma par space then split by space to get an array of words

     

    Filter condition expression (use advanced mode): @and(equals(item(), toUpper(item())), greater(length(item()), 1))

     

    Note: it checks for each word if word equals its capitalized version and if it is greater than 1 char to exclude non word.

     

    Results:

    SamLed_1-1707905426820.png

     

    ______________________________________________________________

    If I have answered your question, please Accept the post as solution.
    If you like my response, please Thumbs Up.

     

  • StillLearning_ Profile Picture
    38 on at

    so this is working now (I can extract the capitalised words) but I can't seem to do anything with them now - the 'split text' function doesn't seem to work on the output of this ?  

     

    The result being that when I try and use the capitalised words later in the flow, it either doesn't work at all or I get this:  ["SMITH","PHILLIP","GRACE"]  rather than SMITH, PHILLIP, GRACE

     

    Are you able to assist in explaining how I can split the text, once it returns in the above 'array' ? 

     

     

  • StillLearning_ Profile Picture
    38 on at

    Also - is there a way to adjust the formula to do the same thing for the lower case words (Timothy, Fairmont, Sally-Louise)?

  • SamLed Profile Picture
    2,340 Moderator on at

    Hi @StillLearning_,

     

    SamLed_0-1707953636908.png

    Expression: 

    @and(and(not(equals(item(), toUpper(item()))), greater(length(item()), 1)), and(not(contains(item(), '(')),not(contains(item(), ')'))))

     

    and(not(equals(item(), toUpper(item()))), greater(length(item()), 1)) part exclude any Upper cased item and 1 char length ones.

     

    and(not(contains(item(), '(')),not(contains(item(), ')') excludes any item containing '(' or ')'. 

     

    results:

    SamLed_1-1707953905526.png

     

    [Edit] I corrected expression, bad copy/paste, added missing right parenthesis.

    ______________________________________________________________

    If I have answered your question, please Accept the post as solution.
    If you like my response, please Thumbs Up.

  • SamLed Profile Picture
    2,340 Moderator on at

    Hi @StillLearning_ ,

     

    To convert string into array you use split(string, separator), to revert the conversion use join(array, separator):

    SamLed_2-1707954242487.png

    expression: join(body('Filter_array'), ',')

     

    Results:

    SamLed_3-1707954295286.png

    ______________________________________________________________

    If I have answered your question, please Accept the post as solution.
    If you like my response, please Thumbs Up.

     

  • StillLearning_ Profile Picture
    38 on at

    I have tried this expression - with the same "from" formula:

    split(replace(outputs('Compose'), ',',''), ' ')  -  but it is telling me it is invalid ..

     

    StillLearning__1-1707954602801.png

     

     

  • SamLed Profile Picture
    2,340 Moderator on at

    That's the filter expression which is failing not the from one, it lacks a parenthesis between the 2 first and 😉

    ______________________________________________________________

    If I have answered your question, please Accept the post as solution.
    If you like my response, please Thumbs Up.

  • StillLearning_ Profile Picture
    38 on at

    Sorry please forgive my ignorance (you have been so helpful!) -  what is it I am missing ? 

    This is what i am trying, but it is giving me the above 'invalid' result.. 

     

    From:  split(replace(outputs('Compose'), ',',''), ' ')

    Expression@And(and(not(equals(item(), toUpper(item()))), greater(length(item()), 1)), and(not(contains(item(), '(')),not(contains(item(), ')'))

     

     

  • SamLed Profile Picture
    2,340 Moderator on at

    Don't worry, I'm glad to help 😉

     

    in your sceenshot, I highlighted where it lacks a "(":

    SamLed_0-1707956638745.png

    ______________________________________________________________

    If I have answered your question, please Accept the post as solution.
    If you like my response, please Thumbs Up.

     

  • SamLed Profile Picture
    2,340 Moderator on at

    Lacks also one ")" at the end, I think 

    SamLed_1-1707956746621.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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 552

#2
Valantis Profile Picture

Valantis 388

#3
11manish Profile Picture

11manish 375

Last 30 days Overall leaderboard