Eric Beattie wrote:
> 
> Does anyone have a quick and dirty method of extracting all the numeric
> characters in a string using MapBasic?

Here's one way to do it:

function CleanString (byval sText as string) as string
dim i, j as integer
dim sResult, c as string

   j = Len(sText)
   if j = 0 then 
      CleanString = ""
      exit function
   end if

   for i = 1 to j
      c = mid$(sText, i, 1)
      if instr(1, "0123456789", c) = 0 then
         'character is not a number
         sResult = sResult + c
      end if
   next

   CleanString = sResult
end function

- Bill Thoen
------------------------------------------------------------
GISnet, 1401 Walnut St., Suite C, Boulder, CO  80302
tel: 303-786-9961, fax: 303-443-4856
mailto:[EMAIL PROTECTED], http://www.ctmap.com/gisnet
------------------------------------------------------------
----------------------------------------------------------------------
To unsubscribe from this list, send e-mail to [EMAIL PROTECTED] and put
"unsubscribe MAPINFO-L" in the message body, or contact [EMAIL PROTECTED]

Reply via email to