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
Super User
Super User

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

View solution in original post

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (1,190)