Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Locating a number within a character string
Message
 
 
À
28/04/2000 22:48:00
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00364345
Message ID:
00364745
Vues:
31
This message has been marked as the solution to the initial question of the thread.
Hi Doyle,

Try this

m.position = AT( LEFT( CHRTRAN(m.address, CHRTRAN(m.address, "0123456789", ""), ""),1), m.address)

--
>Thank you for responding. I am looking for a function to return the position of the first occurance
> of any number in a character string. ie m.address = "El Paso, Tx. 79902 "
>? at(m.address,FirstNumericalOccurance) would return 14
>
>I have written several routines which return the value, but they are too process intense and slow for a large table:
>
>m.address = "El Paso, Tx. 79902 "
>m.position = 0
>i=1
>for i=1 to len(m.address)
>StringValue = substr(m.address,i)
>IF type(StringValue) = "N"
> m.position = i
> break
>ENDIF
>NEXT
>
>If m.position = 0
> ? "No number"
>ELSE
> ? "The first number is at "+val(m.position)
>ENDIF
>
>Thank you very much for any input.
>
>DG
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform