>I'm looking for the best way to find a specific characters in a string.
>
>Assuming I have a memo field. I search for a specific character. Lets say it's on position 143. Now, that I have found that position, I need to find the last occurence of a specific character before that position.
>
>So, if I have the following string:
>
>The Montreal Canadians will try to win their 7 games in a row.
>
>Lets say I was looking for the string "mes". The position would then be 50. I then need to find the last occurence of a specific character before position 50. I am looking for a space. So, the position I am looking for is 47.
>
>I wouldn't want to use a DO WHILE approach and skipping a minus one character at a time until I find the space. I am looking for something more direct.
As always, I like COM solutions - Michel, you might want to try using the Vbscript.RegExp COM object's Execute method, which will return a collection of expresssion matches in the string, each collection member has a .value, the expression match, a .FirstIndex, the 1-indexed position of the match in the string, and a .Length, the length of the match. You can iterate the collection using a FOR EACH loop. As usual, the WSH site link is in my .sig block!