How I can remove all non alpha-numeric characters from a string

#include <hmg.ch>
 
/*
   Remove all non alpha-numeric characters from a string
*/

PROC MAIN

   cOriginal := "=<abc_-.#@123>#+-.,"
   cCleaned  := RemNAN( cOriginal )
   
   MsgBox( "Original : " + cOriginal + STR( LEN( cOriginal ), 3 ) +;
            CRLF + ; 
           "Cleaned  : " + cCleaned  + STR( LEN( cCleaned ), 3 ) )  
RETU

*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

FUNC RemNAN( cString )

   LOCAL cRVal  := "",;
         c1Char := ""
       
   FOR EACH c1Char IN cString
      cRVal += IF( ISALPHA( c1Char ) .OR. ISDIGIT( c1Char ), ;
               c1Char, "" )         
   NEXT   
      
RETU cRVal

*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

remNAN
Advertisements

One response to “How I can remove all non alpha-numeric characters from a string

  1. Pingback: How I Can Do … | Viva Clipper !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s