xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

CharRepl()

Searches a list of characters and replaces them with a corresponding list.

Syntax

CharRepl( <cSearch> , ;
          <cString> , ;
          <cReplace>, ;
         [<lOnePass>] ) --> cResult

Arguments

<cSearch>
This is a character string holding the list of characters to search for in <cString>.
<cString>
This is the character string to process.
<cReplace>
This is a character string holding the replacemnt list of characters. It must be of the same langth as <cSearch>. If characters of <cSearch> are found in <cString>, they are replaced with the corresponding character of <cReplace>
<lOnePass>
This parameter defaults to .F. (false) so that the search and replace operation is repeated until no more match is found. When <lOnePass> is .T. (true), the function processed <cString> only once.

Return

The function returns a string where all characters contained in <cSearch> are replaced with the corresponding characters of <cReplace>. The string <cString> is returned unchanged when no character of <cSearch> is found.

Info

See also:PosRepl(), RangeRepl(), WordRepl(), WordToChar()
Category: CT:String manipulation , Character functions
Source:ct\charrepl.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example shows results of CharRepl()

   PROCEDURE Main
      LOCAL cString := "xHarbour compiler"

      ? CharRepl( "aeiou", cString, "AEIOU" ) // result: xHArbOUr cOmpIlEr

      ? CharRepl( "xmr"  , cString, "123" )   // result: 1Ha3bou3 co2pile3
   RETURN

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