Difference between revisions of "Documentation/How Tos/Calc: SUBSTITUTE function"
From Apache OpenOffice Wiki
		< Documentation | How Tos
		
		
OOoWikiBot (talk | contribs) m (Robot: Automated text replacement %s)  | 
				m  | 
				||
| Line 29: | Line 29: | ||
* [[Documentation/How_Tos/Calc: Functions listed alphabetically|Functions listed alphabetically]]  | * [[Documentation/How_Tos/Calc: Functions listed alphabetically|Functions listed alphabetically]]  | ||
* [[Documentation/How_Tos/Calc: Functions listed by category|Functions listed by category]]}}  | * [[Documentation/How_Tos/Calc: Functions listed by category|Functions listed by category]]}}  | ||
| − | [[Category: Documentation/Reference/Calc]]  | + | [[Category: Documentation/Reference/Calc/Text functions]]  | 
Revision as of 13:10, 17 May 2010
SUBSTITUTE
Substitutes new text for old text in a text string.
Syntax:
SUBSTITUTE(originaltext; oldtext; newtext; which)
- In originaltext, removes oldtext, inserts newtext in its place, and returns the result. oldtext and newtext can have different lengths.
 
- which (optional) is a number which specifies which occurrence of oldtext to replace (counting from the left). If omitted, all occurrences are replaced.
 
Example:
SUBSTITUTE("castle"; "stl"; "v")
- returns cave.
 
SUBSTITUTE("a red red rose"; "red"; "white")
- returns a white white rose. All occurrences of red are replaced if which is omitted.
 
SUBSTITUTE("a red red rose"; "red"; "and white"; 2)
- returns a red and white rose. The second occurrence of red is replaced.