cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ScottRoso
Frequent Visitor

Splitting a string by uppercase letter

Hey all,

I am severely stuck on this issue. I have a string that was created called GetName which contains a dynamically changing name based upon what is uploaded for example: JohnSmith, JaneDoe etc. What I want to do is to be able to separate this string based upon the location of an uppercase letter. There is no space or other special character that I can use to identify where I want the split to be so I am hoping that someone may have a better idea to perform the action.

 

Thanks for any and all input!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ekarim2020
Super User
Super User

Here is one method:

ekarim2020_0-1645037089482.png

 

Snag_1f902e5.png

 

 

FROM:
range(1,sub(length(variables('varName')),1))

MAP:
if(contains(variables('varUpper'),substring(variables('varName'),item(),1) ), item(),0)

 

 

Snag_192e5d8.png

Snag_1962d14.png

 

LENGTH:
first(body('Filter_array'))

 

 

Snag_19664ae.png

 

STARTING POSITION:
first(body('Filter_array'))

LENGTH:
sub(length(variables('varName')), first(body('Filter_array')))

 

Here is some sample runtime output:

Snag_1b04ef5.png


Ellis
____________________________________
If I have answered your question, please mark the post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

8 REPLIES 8
DamoBird365
Microsoft
Microsoft

Hi @ScottRoso 

 

I've given this a go as follows:

 

A list of upper case letters A-Z, can be split() to create an array and the used with contains() (case sensitive) and indexof to get the position of Uppercase letters.

 

Select input:

split(outputs('ComposeUpperLetters'),',') 

 

DamoBird365_0-1645038019578.png

letter: 

if(contains(outputs('ComposeName'),item()),item(),'')
location:
if(contains(outputs('ComposeName'),item()),indexof(outputs('ComposeName'),item()),0)
 
This gives me an array of letters and locations, all bar 1 will be 0 and i can use a filter.
 
FROM split(outputs('ComposeName'),',')
item()?['location'] greater than 1
 
DamoBird365_1-1645038124328.png

 

Output:

 

DamoBird365_2-1645038172349.png

 

Please consider accepting my answer as a solution if it helps to solve your problem.

Cheers
Damien

Please take a look and subscribe to my YouTube Channel for more Power Platform ideas and concepts, or take a look at my website. Thanks

ekarim2020
Super User
Super User

Here is one method:

ekarim2020_0-1645037089482.png

 

Snag_1f902e5.png

 

 

FROM:
range(1,sub(length(variables('varName')),1))

MAP:
if(contains(variables('varUpper'),substring(variables('varName'),item(),1) ), item(),0)

 

 

Snag_192e5d8.png

Snag_1962d14.png

 

LENGTH:
first(body('Filter_array'))

 

 

Snag_19664ae.png

 

STARTING POSITION:
first(body('Filter_array'))

LENGTH:
sub(length(variables('varName')), first(body('Filter_array')))

 

Here is some sample runtime output:

Snag_1b04ef5.png


Ellis
____________________________________
If I have answered your question, please mark the post as Solved.
If you like my response, please give it a Thumbs Up.

@ekarim2020  I am trying your method but for whatever reason when I am typing out the "map" portion of the code

if(contains(variables('varUpper'),substring(variables('varName'),item(),1) ), item(),0)

 

it constantly reverts back to the following: if(contains(variables('varUpper'),substring(variables('varName'))))

 

Any idea on why it would do that/possible fixes?

Sorry, I should have added a note to Switch to text mode for the Select action:

Snag_1f804cf.png

Ellis

@ekarim2020The weird thing is that I have been in text mode and it still reverts for some reason. It does not seem to want to enter any of the "item" function.

@DamoBird365Could you explain a little more on the "Select" step? The note shows split(outputs('ComposeUpperLetters'), ',')contains(outputs('ComposeName'), item())  The system does not like this and throws a flow error message. Thanks again for your help.

Snag_34f27d3.png

 

If you create the flow and then copy-and-paste the expression below, does it allow you to save?

if(contains(variables('varUpper'),substring(variables('varName'),item(),1) ), item(),0)

 

Ellis

@ekarim2020For whatever reason the copy and paste seemed to work. I do have a slightly different issue now though but the entire process works. Thank you!

Helpful resources

Announcements
 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Users online (1,811)