xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

WordRepl()

Replaces words (2-byte sequences) in a string with a specified word.

Syntax

WordRepl( <cWordList> , ;
          <cString>   , ;
          <cReplace   , ;
          [<lSkipWords>]) --> cResult

Arguments

<cWordList>
This is a character string holding 2-byte sequences (words) to search for in <cString>.
<cString>
This is the character string to process.
<cReplace>
This is a character string holding 2-byte sequences (words) which replace the corresponding words of <cWordList> in <cString>.
<lSkipWords>
This parameter defaults to .F. (false) so that the function scans <cString> in steps of one byte. When set to .T. (true), the function scans the string in steps of two bytes. This is of relevance when CSetAtMuPa() is set to .T. (true).

Return

The function scans <cString> and searches the words specified with <cWordList>. All words found are replaced with the corresponding word listed in <cReplace>. The modified character string is returned.

Info

See also:CSetAtMuPa(), CharRepl(), CSetRef()
Category: CT:String manipulation , Character functions
Source:ct\wordrepl.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example displays results of WordRepl()

   PROCEDURE Main
      LOCAL cString := "abab12cd1212cdefef"

      ? WordRepl( "12", cString, "XY" )
                     // result: ababXYcdXYXYcdefef

      ? WordRepl( "abef", cString, "RSTU" )
                     // result: RSRS12cd1212cdTUTU
   RETURN

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