Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Best way to find a specific character
Message
De
24/02/2000 19:44:07
 
 
À
24/02/2000 15:34:57
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00337052
Message ID:
00337235
Vues:
10
>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!
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform