Difference between revisions of "Manuals/calci/REPLACE"

From ZCubes Wiki
Jump to navigation Jump to search
Line 2: Line 2:
  
 
*where <math>otext</math> is the original or old text
 
*where <math>otext</math> is the original or old text
*<math>snum</math> is the position of character in old text
+
*<math>snum</math> is the character position in old text
*<math>noc</math> is the number of characters
+
*<math>noc</math> is the number of characters to be replaced in old text
*<math>ntext</math> is the new text that replaces the characters in old text.
+
*<math>ntext</math> is the new text that replaces the characters in old text
  
 
REPLACE() replaces a part of the text string with a different text string.
 
REPLACE() replaces a part of the text string with a different text string.
Line 21: Line 21:
 
*<math>snum</math> and <math>noc</math> should be positive numbers.
 
*<math>snum</math> and <math>noc</math> should be positive numbers.
 
*If <math>snum</math> and <math>noc</math> are non-integers, they are truncated.
 
*If <math>snum</math> and <math>noc</math> are non-integers, they are truncated.
*If <math>snum</math> is &gt; the length of string, Calci assumes it to be '0'(zero) and new text is appended before old text.
+
*If <math>snum</math> &gt; 'length of <math>otext</math>' , Calci assumes it to be '0'(zero) and new text is appended before old text.
 
*If any arguments are invalid, Calci displays an #ERROR message.
 
*If any arguments are invalid, Calci displays an #ERROR message.
  
Line 38: Line 38:
 
| class="  " |
 
| class="  " |
 
| class="  " |
 
| class="  " |
 
  
 
|- class="even"
 
|- class="even"
Line 44: Line 43:
 
| class="  " |
 
| class="  " |
 
| class="  " |
 
| class="  " |
 
  
 
|- class="odd"
 
|- class="odd"
Line 50: Line 48:
 
| class="  " |
 
| class="  " |
 
| class="  " |
 
| class="  " |
 
  
 
|- class="even"
 
|- class="even"
Line 56: Line 53:
 
| class="  " |
 
| class="  " |
 
| class="  " |
 
| class="  " |
 
  
 
|- class="odd"
 
|- class="odd"

Revision as of 07:26, 28 December 2013

REPLACE(otext, snum, noc, ntext)

  • where is the original or old text
  • is the character position in old text
  • is the number of characters to be replaced in old text
  • is the new text that replaces the characters in old text

REPLACE() replaces a part of the text string with a different text string.

Description

REPLACE(otext, snum, noc, ntext)

For Example,

REPLACE("WELCOME",4,4,"-COME") returns WEL-COME

In above example, original text is replaced with new text from 4th character to next 4 characters.

  • and should be enclosed in quotes.
  • and should be positive numbers.
  • If and are non-integers, they are truncated.
  • If > 'length of ' , Calci assumes it to be '0'(zero) and new text is appended before old text.
  • If any arguments are invalid, Calci displays an #ERROR message.

Examples

ColumnA ColumnB ColumnC
123456
replace
ABCDEF
Mango
=REPLACE(A1,2,1,"two") : Replaces second character from old text with "two". Returns 1two3456 as output.
=REPLACE(A2,3,5,"PLACE") :Replaces 5 characters from old text starting from 3rd position with upper case "PLACE". Returns rePLACE as output.
=REPLACE(A3,6,1,"fghijk") : Replaces 6th character from old text with lower case "fghijk". Returns ABCDEfghijk as output.
=REPLACE(A4,8,1,"Apple ") : Appends "Apple " before old text as snum is greater than length of old text. Returns Apple Mango as output.

See Also

References