Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Advice how to replace special chars with blank
Message
 
 
À
09/02/2005 14:53:21
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00985315
Message ID:
00985336
Vues:
16
Here is a procedure I use:
PROCEDURE StripString
   LPARAMETERS tcString, tnAllow
   IF VARTYPE(tcString) <> [C]
      RETURN NULL
   ENDIF
   IF VARTYPE(tnAllow) <> [N]
      RETURN NULL
   ENDIF
   LOCAL lnType, lcReturn
   lnType = ABS(tnAllow)
   LOCAL lcAllowed
   DO CASE
      CASE lnType = ALLOW_ALPHA_ONLY
         lcAllowed = [ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz]
      CASE lnType = ALLOW_NUMBER_ONLY
         lcAllowed = [1234567890]
      CASE lnType = ALLOW_ALPHA_NUMERIC
         lcAllowed = [ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890]
   ENDCASE
   IF tnAllow < 0  && not allowed
      lcReturn = CHRTRAN(tcString, lcAllowed, [])
   ELSE
      lcReturn = CHRTRAN(tcString, CHRTRAN(tcString, lcAllowed, []), [])
   ENDIF
   RETURN lcReturn
ENDPROC
>Hi all,
>
>I have used this line to test and works fine
>
>STRTRAN(ALLTR("xxx'xxxxxx"), "'" , "" ) gives me xxxxxxxxx GOOD output.
>
>what happened if I like to replace everything other THAN THAN
>
>letters,numbers,space,period,dash,underscore,brackets
>A..Z, a..z, 0..9, space, . , - , _ , ()
>
>i.e :
>
>' with blank
>" with blank
>; with blank
>? with blank
>....
>....
>...
>
>in the single process if possible.
>
>Any advice or coding samples would be really appreciated .
>TIA
Mark McCasland
Midlothian, TX USA
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform