I was working on finding all prepositions in a string. I have tried the index method but it doesnt work when there are multiple words in the string. So here is what I am trying to achieve.
source string
1. " I want to know the code"
2. "tobey"
Expected Results: I want to select the first record because it has the word "to" in it. Similarly I would want to identify rows with other prepositions like if, for, to, from etc. Although the second string has got the substring "to" in it, I wouldn't want to select that.
The source string is not restricted to one word which is causing me the trouble. there are multiple words coming from the source and I have a list of preposition words that I need to identify. Is there any other technique that I can apply here?
index('| of | in | to |', '| ' : sourcecolumn : ' |',1 )
with the above function I am getting a match when the source column is having a single word like "IF" or "TO" but it wouldn't match it when the word is in between a string like "I want to enjoy Christmas"
And don't use pipes unless your values are pipe delimited in your source string. In other words, match what is existing in both what you tack on each end of the source string and what you wrap each word with. Your example showed spaces, hence my posted example. And then as Ray noted, you need to do each word separately. If you don't want to go looping, set up a stage variable for each.
-craig
"You can never have too many knives" -- Logan Nine Fingers