Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Removing characters from string
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00620890
Message ID:
00620916
Vues:
14
Hello James,
>what i am trying to do is trim certain data within the field. an example is as follows:
>table field data: exampleofdata-1234
>what i want to do is trim the right side so that the data within the data field just says:
>exampleofdata.


So I'll presume you are trying to get rid if the hyphen and everything to the right of it in one particular field of a table.

>i am able to determine whether or not the data has the hyphen with a statement like:
> if right(rtrim(substr(table.field, 1, 25)),5) = '-'
>what i cannot figure out is how to get rid of those last 5 characters from the string.


If the field name is xx
*To locate the hyphen
? AT(xx,"-")   && shows the position number within the field
*expanding to pick only the stuff to the left of the hyphen
? SUBSTR(xx,1,AT("-",xx)-1)
*and to save that truncated data:
REPLACE xx WITH SUBSTR(xx,1,AT("-",xx)-1)   && operates on current record only
HTH
Randy Bosma
VFP - Because life is too short to code in something else...
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform