Skip to main content

Notifications

Power Automate - Building Flows
Answered

Using Split with a count of characters to the left or right?

Posted on by 251

Hi all,

 

I am running into an issue where, I suspect that split has the functionality and i'm simply not looking for the right thing to find the examples i'd like.

 

What i want is to use split like how excel works, where you can count characters to the right or left to exclude/include.

so for instance, i have a message like this:
BTF_CWING_LOW_TEMP **= 2021-11-19 14:10:55

where, i'd like to split on the left by **, but, the character 3rd in the string = could be any of a number of different characters, so, i'd like to split it at the space before 2021, but, i want to account for whatever that character is. so if i were doing this in excel, i'd count 2 to the right when splitting - does that make sense?

I look forward to your responses, and thanks for your time!

 

  • Seuadr Profile Picture
    Seuadr 251 on at
    Re: Using Split with a count of characters to the left or right?

    you know, i had not considered AI builder - but i could see where that might be a better option since i could train it to recognize the text i want. thanks!

  • Verified answer
    ScottShearer Profile Picture
    ScottShearer 25,178 on at
    Re: Using Split with a count of characters to the left or right?

    @Seuadr 

    I'll be honest - if you can get this done it will be really ugly...  There are too many variables.  For example, the data  at the start of the string (Low Limit out-of-range, Alarm change-of-state )  is not consistent making it difficult to impossible to break out.  

    As you have suggested, you could try splitting on ** and then using a string functions to go to a certain character position, etc.  If you want to go that way, you'll be using the substring(), length(), indexOf(), lastIndexOf() and trim expressions.  

    I'm not saying that you can't get there, but it will be a whole lot of work and what you create may not be bullet proof........

    If you have a premium license, you might try exploring the use of the AI builder functionality.  I suspect that using AI is a better way to go.

     

     

  • Seuadr Profile Picture
    Seuadr 251 on at
    Re: Using Split with a count of characters to the left or right?

    @ScottShearer 

     

    Sure! so, for instance, i have this message:

    Low Limit out-of-range BTF_CWING_LOW_TEMP **= 2021-11-19 14:10:55


    ultimately, i want to end up with:
    BTF_CWING_LOW_TEMP,
    **=,

    2021-11-19


    here is another example:
    Alarm change-of-state WEL_HW__HX9_HIGH_LIMIT **& 2021-11-17 12:42:48

     

    WEL_HW__HX9_HIGH_LIMIT,

    **&,

    2021-11-17

     

    the characters in the middle - **= and **& are just a couple of examples, there are a number of special characters that could happen after ** so, i was thinking that if i were doing this in excel, i'd first split it at "-" and count 5 characters to the right, giving me:

    WEL_HW__HX9_HIGH_LIMIT **& 2021-11-17 12:42:48

    then i'd split it at "**" and count 1 character to the right, to give me:
    2021-11-17 12:42:48

    and then at "**" to the left, and trim to give me:
    WEL_HW__HX9_HIGH_LIMIT

     

    though, while writing this it occured to me that if i were to split first with a space delimiter i'd end up with:

    WEL_HW__HX9_HIGH_LIMIT,

    **&,

    2021-11-17 

     

    in an array that i could then select elements from?

  • ScottShearer Profile Picture
    ScottShearer 25,178 on at
    Re: Using Split with a count of characters to the left or right?

    @Seuadr 

    I am not 100% clear on your requirement.  Can you provide a couple of examples of a string and your required output?

     

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

October 2024 Newsletter…

October 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #4 How to Conntact Support…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 142,733

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,750

Leaderboard