Search a text from sentence

Certified Lead Developer

Hello All,

My requirement is to search a word from the sentence.

for example: sentence(single text): "The document is AI contain the data" 

search text :"AI"    

Output: true

The desired result is:- get that the sentence is having the search text but only if exact word is there no if that alphabet is any word.

For example: "The document  contain the data"

search text: "ai".

output: false

regards

sahil

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Hi , You can use find() or search() function to check if a word is there or not in your text and then add a condition to get the boolean value. find or search function gives you the index of the word you are searching in the text string. so if you get 0 as a result then it means the word you searched is not available hence you can get output as false and if it gives any non zero integer , it means you found the word in your text string. See below example.

    a!localVariables(
      local!position:find("AI","The document is AI contain the data",),
      if(
        local!position=0,
        false,
        true
      )
    )
    

Reply
  • 0
    Certified Lead Developer

    Hi , You can use find() or search() function to check if a word is there or not in your text and then add a condition to get the boolean value. find or search function gives you the index of the word you are searching in the text string. so if you get 0 as a result then it means the word you searched is not available hence you can get output as false and if it gives any non zero integer , it means you found the word in your text string. See below example.

    a!localVariables(
      local!position:find("AI","The document is AI contain the data",),
      if(
        local!position=0,
        false,
        true
      )
    )
    

Children
No Data