xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

CharOnly()

Removes all characters but the specified ones from a string

Syntax

CharOnly( <cRemaining>, <cString> ) --> cResult

Arguments

<cRemaining>
This character string defines the characters that are to remain in the result string.
<cString>
This is the character string to process.

Return

The function removes all characters from <cString> except those contained in <cRemaining> and returns the result.

Info

See also:CharOne(), CharRem(), WordOnly()
Category: CT:String manipulation , Character functions
Source:ct\charonly.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// 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

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe