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
Because you want to explicitly find if the object is a word (not letters within another word), I don't think you can directly use find / search / substitute. Instead, I'd recommend splitting all the words in your sentence by a space and then comparing each word individually. Here's an example:
a!localVariables( local!sentence: "The document is AI and contains the data", or( a!forEach( items: split(local!sentence, " "), expression: fv!item = "AI" ) ) )
Depending on what you expect your text input to be, you might need other logic as well. For instance, if you expect to receive multiple sentences or punctuation, I'd also recommend stripping out all of the punctuation before doing the check using the stripwith() function.