Difference between revisions of "Documentation/How Tos/Calc: SUBSTITUTE function"
From Apache OpenOffice Wiki
< Documentation | How Tos
(Initial content) |
m |
||
| (10 intermediate revisions by 6 users not shown) | |||
| Line 1: | Line 1: | ||
| − | __NOTOC__ | + | {{DISPLAYTITLE:SUBSTITUTE function}} |
| + | {{Documentation/CalcFunc TextTOC | ||
| + | |ShowPrevNext=block | ||
| + | |PrevPage=Documentation/How_Tos/Calc:_SEARCH_function | ||
| + | |NextPage=Documentation/How_Tos/Calc:_T_function | ||
| + | }}__NOTOC__ | ||
== SUBSTITUTE == | == SUBSTITUTE == | ||
| Line 6: | Line 11: | ||
=== Syntax: === | === Syntax: === | ||
<tt>'''SUBSTITUTE(originaltext; oldtext; newtext; which)'''</tt> | <tt>'''SUBSTITUTE(originaltext; oldtext; newtext; which)'''</tt> | ||
| − | : | + | : In <tt>'''originaltext'''</tt>, removes <tt>'''oldtext'''</tt>, inserts <tt>'''newtext'''</tt> in its place, and returns the result. <tt>'''oldtext'''</tt> and <tt>'''newtext'''</tt> can have different lengths. |
: <tt>'''which'''</tt> (optional) is a number which specifies which occurrence of <tt>'''oldtext'''</tt> to replace (counting from the left). If omitted, <u>all</u> occurrences are replaced. | : <tt>'''which'''</tt> (optional) is a number which specifies which occurrence of <tt>'''oldtext'''</tt> to replace (counting from the left). If omitted, <u>all</u> occurrences are replaced. | ||
| Line 20: | Line 25: | ||
: returns <tt>'''a red and white rose'''</tt>. The second occurrence of <tt>'''red'''</tt> is replaced. | : returns <tt>'''a red and white rose'''</tt>. The second occurrence of <tt>'''red'''</tt> is replaced. | ||
| − | + | {{SeeAlso|EN| | |
| − | + | * [[Documentation/How_Tos/Calc: REPLACE function|REPLACE]] | |
| − | + | * [[Documentation/How_Tos/Calc: FIND function|FIND]] | |
| − | + | * [[Documentation/How_Tos/Calc: SEARCH function|SEARCH]] | |
| − | + | * [[Documentation/How_Tos/Calc: Text functions|Text functions]] | |
| + | |||
| + | * [[Documentation/How_Tos/Calc: Functions listed alphabetically|Functions listed alphabetically]] | ||
| + | * [[Documentation/How_Tos/Calc: Functions listed by category|Functions listed by category]]}} | ||
| + | [[Category: Documentation/Reference/Calc/Text functions]] | ||
Latest revision as of 15:40, 2 February 2024
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.
See Also