next up previous contents index
Next: RIGHT Up: A. Function Reference Previous: REPEAT, REPT   Contents   Index


REPLACE, XLREPLACE

Syntax: REPLACE(S1, N1, N2, S2)
  XLREPLACE(S1, N1, N2, S2)

S1 = a string value
N1 = a numeric value
N2 = a numeric value
S2 = a string value

REPLACE returns the string formed by replacing the N2 characters starting at position N1 in string S1 with string S2.

In REPLACE the index of the first character of S1 is 0 (zero-based indexing). In XLREPLACE the index of the first character of S1 is 1 (one-based indexing) for compatibility with Excel's REPLACE function. Otherwise, the two functions are identical.

Examples:

REPLACE(``John'', 1, 3, ``ack'') = ``Jack''

XLREPLACE(``John'', 1, 3, ``ack'') = ``ackn''

XLREPLACE(``John'', 2, 3, ``ack'') = ``Jack''

REPLACE(``John'', 2, 3, ``ack'') = ``Jack'' (in Excel compatibility mode)

REPLACE(E1, 8, 3, ``Log'') = ``Expense Logort'', where E1 = ``Expense Report''

REPLACE(E1, 8, 6, ``Log'') = ``Expense Log'', where E1 = ``Expense Report''

REPLACE(``ABC'', 0, 0, ``XYZ'') = ``XYZABC''

Excel function: XLREPLACE is compatible with Excel's REPLACE (In Excel compatibility mode, the ``XL'' prefix is not used.)


next up previous contents index
Next: RIGHT Up: A. Function Reference Previous: REPEAT, REPT   Contents   Index
SpreadScript User's Guide, Version 1.2
Grey Trout Software
02 March 2003