xHarbour Reference Documentation > Function Reference |
Removes all characters but the specified ones from a string
CharOnly( <cRemaining>, <cString> ) --> cResult
The function removes all characters from <cString> except those contained in <cRemaining> and returns the result.
See also: | CharOne(), CharRem(), WordOnly() |
Category: | CT:String manipulation , Character functions |
Source: | ct\charonly.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example extracts digits from formatted phone numbers PROCEDURE Main LOCAL cDigits := "0123456789" ? CharOnly( cDigits, "(555) 45 67 788" ) // result: 5554567788 ? CharOnly( "0123456789", "555 / 345 9876" ) // result: 5553459876 RETURN
http://www.xHarbour.com