Hi All,
I was able to count strings based on what I heard here.
Thank you very much.
I could do something I wanted to add.
When I find the letter "abc", I want to concatenate the two letters before and three letters after that letter.
(String)
asfweabcgfrthoabcopfgrkpabchjk
(String to retrieve)
Every time I find it, I want to write a string to my email.
In the way of the image, the same character is taken out many times.
I want to write the extracted strings one by one to the mail.
Can you repeat the letter extraction using "Do Until"?
Kind Regards.
Solved! Go to Solution.
Hi @DrinkWater
I think I have managed to get to the solution that you are after.
In my example I have set a variable as your string but you would just need to change this to be your input value.
Initialise 3 variables for the following
TestString - the string that we want to process
TEMP - a temporary holding string (you'll see why later)
StringArray - to hold the values we pull out of TestString
Then we create a Do Until action. Set the properties of this to
indexOf(variables('TestString'),'abc') is equal to -1
When the indexOf function cannot find the string 'abc' it will return a -1 and then exit the loop.
Within the loop you then want to add an Append to array variable action. The variable we will append to is StringArray and you will need to set the value to
substring(variables('TestString'),sub(indexOf(variables('TestString'),'abc'),2),8)
This will put out the first instance of "abc" with the 2 characters before and the 3 after (8 character length)
Finally, using a Set variable action, set the variable TEMP to the value
substring(variables('TestString'),add(3,indexOf(variables('TestString'),'abc')),sub(length(variables('TestString')),add(3,indexOf(variables('TestString'),'abc'))))
This will set it to everything in the string TestString minus the part we just extracted. You then need to set TestString to the value in TEMP. We have to do it this way as we are not able to set TestString to an expression that references itself.
As this loops, the value of TestString will get shorter and shorter until there are no instances of 'abc' left.
Last step is to use a Join action to join the contents of your variable StringArray using HTML (such as <br> ). Then you simply include the output from the Join action somewhere in your email at the end of the process.
Hope that all makes sense.
Proud to be a Flownaut!
Follow me on Twitter at @QG_LeeJHarris
Or on LinkedIn at in/leejharris
Hi @DrinkWater
I think I have managed to get to the solution that you are after.
In my example I have set a variable as your string but you would just need to change this to be your input value.
Initialise 3 variables for the following
TestString - the string that we want to process
TEMP - a temporary holding string (you'll see why later)
StringArray - to hold the values we pull out of TestString
Then we create a Do Until action. Set the properties of this to
indexOf(variables('TestString'),'abc') is equal to -1
When the indexOf function cannot find the string 'abc' it will return a -1 and then exit the loop.
Within the loop you then want to add an Append to array variable action. The variable we will append to is StringArray and you will need to set the value to
substring(variables('TestString'),sub(indexOf(variables('TestString'),'abc'),2),8)
This will put out the first instance of "abc" with the 2 characters before and the 3 after (8 character length)
Finally, using a Set variable action, set the variable TEMP to the value
substring(variables('TestString'),add(3,indexOf(variables('TestString'),'abc')),sub(length(variables('TestString')),add(3,indexOf(variables('TestString'),'abc'))))
This will set it to everything in the string TestString minus the part we just extracted. You then need to set TestString to the value in TEMP. We have to do it this way as we are not able to set TestString to an expression that references itself.
As this loops, the value of TestString will get shorter and shorter until there are no instances of 'abc' left.
Last step is to use a Join action to join the contents of your variable StringArray using HTML (such as <br> ). Then you simply include the output from the Join action somewhere in your email at the end of the process.
Hope that all makes sense.
Proud to be a Flownaut!
Follow me on Twitter at @QG_LeeJHarris
Or on LinkedIn at in/leejharris
Hi, @LeeHarris
Wow! Thank you for teaching me.
I want to understand the content.
So I try one by one what is written.
"Do Until action" is doing strange movement.
Every time I repeat 60 times somehow.
Because I can not debug, I can not understand what is happening.
indexOf(variables('TestString'),'abc') is equal to -1
This expression can not be put into the condition as it is.
I have entered expression this way.
Am I wrong like this?
Sorry to bother you again.
Thanks.
Hi @DrinkWater
The way that you have entered the do until expression in your last screen shot is correct. If the loop is repeating 60 times still then it is reaching its maximum executions. Check the variable (currently called TestString) that you are storing the initial string in to make sure that this is not blank.
In terms of debugging, if you are able to execute the Flow then you can check the historic runs via the Flow details screen. From here you can see information on properties/inputs/outputs etc at each step of the process.
Proud to be a Flownaut!
Follow me on Twitter at @QG_LeeJHarris
Or on LinkedIn at in/leejharris
Hi, @LeeHarris
Thank you for teaching me so kindly.
There was a part where I set the variable incorrectly.
I was able to realize what I wanted.
I appreciate it!!
This thread is now closed.
Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.
Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!
User | Count |
---|---|
40 | |
37 | |
36 | |
32 | |
27 |
User | Count |
---|---|
39 | |
37 | |
32 | |
28 | |
22 |