$alphanum
Posted by CrashB
Thursday, May 20, 2004
Description: returns all the alpha-numeric chrs in a string

Usage: $alphanum(string)
Example: $alphanum(hello there, how are you today?)
Returns: hello there how are you today


alias alphanum {
  var %i 1
  var %line $replace($remove($$1-,.),$chr(32),.)
  var %new $null
  while %i <= $len(%line) {
    var %char $mid([ %line ],[ %i ],1)
    var %asc $asc(%char)
    if (%asc == 46) || (%asc == 160) || ((%asc >= 48) && (%asc <= 57)) || ((%asc >= 65) && (%asc <= 90)) || ((%asc >= 97) && (%asc <= 122)) {
      var %new %new $+ %char
    }
    inc %i
  }
  return $replace([ %new ],.,$chr(32))
}
Excellent
Posted by Parasite-FT-
Tuesday, May 25, 2004 05:42am PDT
appears to be a useful function - maybe you guys should make a library of such functions.

naturally Crash's code is always great, but I thought I'd give another method which I hope gives the same results


alias alphanum {
  var %regsub, %regex = $regsub($1-,m~([^a-z0-9\s])~Sig,$null,%regsub)
  return %regsub
}


Cheers,
- Para
Oi
Posted by CrashB
Wednesday, May 26, 2004 03:01am PDT
I need to learn me up some regex....

:(
Submit a comment
Oops! You need to login or register before you can post a comment!

ebaum's world