cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Charline74
Helper III
Helper III

How to split a sentence?

Hello,

 

I would like to cut out the sentence: I want to modify my report - Je veux modifier mon rapport 

 

In order to obtain: modify my report

 

How do I do it?

1 ACCEPTED SOLUTION

Accepted Solutions
eric-cheng
Solution Sage
Solution Sage

Hi @Charline74 ,

 

Can you post a screenshot of your expression.  If you copied and pasted, you need to add @ In front of your expression e.g. @trim(....) etc

 

Screenshot_20210922-012705_Chrome.jpg

 

Screenshot_20210922-012716_Chrome.jpg

 

Screenshot_20210922-012806_Chrome.jpg

 

--------------------------------------------------------------------------
If I have answered your question, please mark my post as a solution
If you have found my response helpful, please give it a thumbs up

Connect on LinkedIn

View solution in original post

10 REPLIES 10
eric-cheng
Solution Sage
Solution Sage

Hi @Charline74 ,

 

Will the sentence always start with 'I want to' amd also include a '-'?

 

--------------------------------------------------------------------------
If I have answered your question, please mark my post as a solution
If you have found my response helpful, please give it a thumbs up

Connect on LinkedIn

Hello @eric-cheng,

Yes 

DamoBird365
Microsoft
Microsoft

Hi @Charline74 

 

Will the sentence always begin "I want to" and have a hyphen?

 

There are several expressions that can help you here.  Split() ? which splits a string into objects of an array.

e.g. split('I want to modify my report - Je veux modifier mon rapport','-')

would give you {"I want to modify my report "," Je veux modifier mon rapport"}

 

There is also replace which replaces a string with another string

e.g. replace('I want to modify my report - Je veux modifier mon rapport', 'I want to ','')

would give you 'modify my report - Je veux modifier mon rapport'.

 

You've also got indexof('modify my report - Je veux modifier mon rapport',' - Je veux')

which would give you the exact integer of where the string ' - Je veux' appears and then by using substring(), you can create a substring of the original, based on the start and length of the substring expression.

e.g. substring('modify my report - Je veux modifier mon rapport', 0, 18)

would return 'modify my report'.

 

Hope that makes sense.

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here and like & subscribe to my YouTube Channel thanks 😉

eric-cheng
Solution Sage
Solution Sage

Hi @Charline74 ,

 

Based on your answer.

 

@trim(replace(first(split('I want to modify my report - Je veux modifier mon rapport','-')),'I want to',''))

 

--------------------------------------------------------------------------
If I have answered your question, please mark my post as a solution
If you have found my response helpful, please give it a thumbs up

Connect on LinkedIn

Thank you, is it possible to do the same thing when the sentence is not the same all the time: Like with an answer to a question in a form that can vary

eric-cheng
Solution Sage
Solution Sage

Hi @Charline74 ,

 

With string manipulation, you will need some sort of pattern. 

 

Are you trying to extract intent? 

 

--------------------------------------------------------------------------
If I have answered your question, please mark my post as a solution
If you have found my response helpful, please give it a thumbs up

Connect on LinkedIn

Example:

This is my question with 2 possible answers:

 

Charline74_0-1632233752839.png

 

In my flow I add this as a title for my UV
I would like to extract only "modify my report" or "create e new report" depending on the answer

Charline74_1-1632233854876.png

 

eric-cheng
Solution Sage
Solution Sage

Hi @Charline74 ,

 

Ok, got you.  

 

You can pass the question / dynamic content into the below formula and replace the portion marked 'x' and in bold

 

trim(replace(first(split(xxxxxxxx,'-')),'I want to',''))

 

Your formula would end up looking like this 

 

trim(replace(first(split(outputs('Get_response_details')?['body/r522d9881578c4f1e906b898025b238e7'],'-')),'I want to',''))

 

You can also find the dynamic content by adding it to a Compose and peeking code

 

Screenshot_20210922-003259_Chrome.jpg

Screenshot_20210922-003307_Chrome.jpg

--------------------------------------------------------------------------
If I have answered your question, please mark my post as a solution
If you have found my response helpful, please give it a thumbs up

Connect on LinkedIn

 

I get this error message :

Charline74_0-1632236489472.png

This is what I typed and I don't see the mistake : 

trim(replace(first(split(outputs('Get_response_details')?['body/r3a6337cb69a942b78efcf0211c6908bb'],'-')),'I want to',"))

 

eric-cheng
Solution Sage
Solution Sage

Hi @Charline74 ,

 

Can you post a screenshot of your expression.  If you copied and pasted, you need to add @ In front of your expression e.g. @trim(....) etc

 

Screenshot_20210922-012705_Chrome.jpg

 

Screenshot_20210922-012716_Chrome.jpg

 

Screenshot_20210922-012806_Chrome.jpg

 

--------------------------------------------------------------------------
If I have answered your question, please mark my post as a solution
If you have found my response helpful, please give it a thumbs up

Connect on LinkedIn

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.

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (2,357)