web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Whole Word Search vs C...
Power Automate
Unanswered

Whole Word Search vs Contains

(1) ShareShare
ReportReport
Posted on by 12

I am doing a keyword search using a condition on the body of an email.  For example, when a new email comes in I want to search for the word "cash" in the body of the email.  If found then I want to do something with the email.  The problem I am having is that when using the Condition action I can set it up to look to see if the word "cash" is Contained in the Body of the email.  That works up to a point.  If the email contains the word "cashmere" then the condition is True as cash is in cashmere.  Is there a better way to search for a whole word so that only cash would be true and not cashmere?  Thanks for any help anyone can share.

Categories:
I have the same question (0)
  • DeepakS Profile Picture
    2,301 Most Valuable Professional on at
    Re: Whole Word Search vs Contains

    Hi @molen ,

    You can achieve this by expression, here is one way of doing it:

    In the condition, use following expression to check if "cash" is in the body email or not:

     

    contains(split(<email body>,' '),'cash')

     

    So you first split the email body with space (' '), then use contains to check if cash is in there or not.

     
    Regards,
    Deepak S 

     

  • molen Profile Picture
    12 on at
    Re: Whole Word Search vs Contains

    Hi - Thanks for your response.  Tried it and it works like you suggested.  What's interesting about this solution is that if I have a sentence like "I like cash." the check comes back as false as it seems to be comparing "cash" to "cash."  Any thoughts on how to account for things like commas, periods, colons, etc.?

  • abm abm Profile Picture
    32,856 Most Valuable Professional on at
    Re: Whole Word Search vs Contains

    Hi @molen 

     

    You could also try it contains cash (with a space) and cash with a dot so that it covers for all using an IF condition. Expression is another way like @DeepakS  suggested and nothing wrong in that but you always needed a delimiter.

     

    Thanks

  • molen Profile Picture
    12 on at
    Re: Whole Word Search vs Contains

    Hi @abm,

     

    Thanks for your response.  That's a way to go as well.  The issue I see there is that I would have to do an if statement for all the special punctuation characters like , . : ; " ' } { ] [ \ | ! @ # $ % ^ & * ( )

     

    Seems like there should be an easier way to search what is essentially a string looking for a whole word.

     

    Maybe you or someone else out there has another idea.

  • abm abm Profile Picture
    32,856 Most Valuable Professional on at
    Re: Whole Word Search vs Contains

    Hi @molen 

     

    Here it is. Define all the character with a space. Then use the split() expression using space as the delimiter. Then iterate the loop and construct each item plus your word (cash) which you want to check with. See below.

     

    image.png

  • Verified answer
    v-bofeng-msft Profile Picture
    on at
    Re: Whole Word Search vs Contains

    Hi @molen :

    I suggest you consider using regular expressions to retrieve text with characters on both sides of "cash" that are not English letters.If the result of the search is true, then the word "cash" exists. If the result is false, then the word "cash" does not exist.

    I've made a test for your reference:

    vbofengmsft_0-1625042698824.png

    Pattern:

     

    [^a-zA-Z]cash[^a-zA-Z]

     

    The Result:

    vbofengmsft_2-1625042778625.png

    vbofengmsft_1-1625042738958.png

    Best Regards,

    Bof

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Tomac Profile Picture

Tomac 497 Moderator

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 477 Super User 2025 Season 2

#3
chiaraalina Profile Picture

chiaraalina 242

Last 30 days Overall leaderboard