POSREPL()

POSREPL()

Replace characters at a certain position within a string

Syntax

        POSREPL( <[@]cString>, <cReplacement>,
                [<nStartPosition>] ) -> cString

Arguments

<cString> [@] Designates the character string within which the particular characters are replaced.

<cReplacementstring> Designates a sequence of characters that, starting at <nStartPos>, replace a portion of

<cString>. <nStartPos> Designates from which character within <cString> the replacement starts.

Returns

POSREPL() returns the modified string.

Description

When you use POSREPL(), you can replace a range of characters within <cString> with another character string <cReplacementstring>. The new characters are exchanged beginning at <nStartPos>.

Notes

. When the <nStartPos> parameter is not specified, the <cReplacementstring> overwrites the end of the string (see examples). . The return value of this function can be suppressed by implementing CSETREF() to save space in working memory.

Examples

       .  Starting at position 3, replace three characters with "XXX":
              ? POSREPL("ABCDEFG", "XXX", 3)         // "ABXXXFG"
           .  Replace the last LEN(<cReplacementstring>) characters:
              ? POSREPL("ABCDEFG", "XXX")            // "ABCDXXX"
           .  The result can be longer than the character string passed.
              ? POSREPL("ABCDEF", "123", 5)          // "ABCD123"
              ? POSREPL("ABCDEF", "123", 6)          // "ABCDE123"

Compliance

POSREPL() is compatible with CT3’s POSREPL().

Platforms

All

Files

Source is pos2.c, library is libct.

Seealso

POSCHAR(), POSDEL(), POSINS(), CSETREF()

Advertisements

2 responses to “POSREPL()

  1. Pingback: Harbour String Functions | Viva Clipper !

  2. Pingback: Harbour All Functions – P | Viva Clipper !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s