# Text Functions

This section contains descriptions of the Text functions.

To access this command...

Insert - Function - Category Text

\<bookmark_value\>ARABIC function\</bookmark_value\>

## ARABIC

Calculates the value of a Roman number. The value range must be between 0 and 3999.

### Syntax

ARABIC (Text)

\<emph\>Text\</emph\> is the text that represents a Roman number.

### Example:

ARABIC("MXIV") returns 1014

ARABIC("MMII") returns 2002

\<bookmark_value\>ASIN function\</bookmark_value\>

## ASC

The ASC function converts full-width to half-width ASCII and katakana characters. Returns a text string.

See https://wiki.documentfoundation.org/Calc/Features/JIS_and_ASC_functions for a conversion table.

### Syntax

ASC("Text")

Text is the text that contains characters to be converted.

\<bookmark_value\>BAHTTEXT function\</bookmark_value\>

## BAHTTEXT

Converts a number to Thai text, including the Thai currency names.

### Syntax

BAHTTEXT(Number)

\<emph\>Number\</emph\> is any number. "Baht" is appended to the integral part of the number, and "Satang" is appended to the decimal part of the number.

### Example:

BAHTTEXT(12.65) returns a string in Thai characters with the meaning of "Twelve Baht and sixty five Satang".

\<bookmark_value\>BASE function\</bookmark_value\>

## BASE

Converts a positive integer to a specified base into a text from the numbering system. The digits 0-9 and the letters A-Z are used.

### Syntax

\<emph\>number\</emph\> is the positive integer to be converted.

\<emph\>radix\</emph\> indicates the base of the number system. It may be any positive integer between 2 and 36.

\<emph\>Minimum length\</emph\> (optional) determines the minimum length of the character sequence that has been created. If the text is shorter than the indicated minimum length, zeros are added to the left of the string.

### Example:

\<bookmark_value\>decimal system; converting to\</bookmark_value\>

BASE(17;10;4) returns 0017 in the decimal system.

\<bookmark_value\>binary system; converting to\</bookmark_value\>

BASE(17;2) returns 10001 in the binary system.

BASE(255;16;4) returns 00FF in the hexadecimal system.

\<bookmark_value\>CHAR function\</bookmark_value\>

## CHAR

Converts a number into a character according to the current code table. The number can be a two-digit or three-digit integer number.

Codes greater than 127 may depend on your system's character mapping (for example iso-8859-1, iso-8859-2, Windows-1252, Windows-1250), and hence may not be portable.

### Syntax

CHAR(number)

\<emph\>number\</emph\> is a number between 1 and 255 representing the code value for the character.

### Example:

CHAR(100) returns the character "d".

="abc" & CHAR(10) & "def" inserts a newline character into the string.

\<bookmark_value\>CLEAN function\</bookmark_value\>

## CLEAN

All non-printing characters are removed from the string.

### Syntax

CLEAN(text)

\<emph\>text\</emph\> refers to the text from which to remove all non-printable characters.

\<bookmark_value\>CODE function\</bookmark_value\>

## CODE

Returns a numeric code for the first character in a text string.

### Syntax

CODE(Text)

\<emph\>Text\</emph\> is the text for which the code of the first character is to be found.

Codes greater than 127 may depend on your system's character mapping (for example iso-8859-1, iso-8859-2, Windows-1252, Windows-1250), and hence may not be portable.

### Example:

CODE("Hieronymus") returns 72, CODE("hieroglyphic") returns 104. The code used here does not refer to ASCII, but to the code table currently loaded.

\<bookmark_value\>CONCATENATE function\</bookmark_value\>

## CONCATENATE

Combines several text strings into one string.

### Syntax

CONCATENATE(Text 1;...;Text 30)

\<emph\>Text 1; text 2; ...\</emph\> represent up to 30 text passages which are to be combined into one string.

### Example:

CONCATENATE("Good ";"Morning ";"Mrs. ";"Doe") returns \<emph\>Good Morning Mrs. Doe\</emph\>.

\<bookmark_value\>DECIMAL function\</bookmark_value\>

## DECIMAL

Converts text with characters from a number system to a positive integer in the base radix given. The radix must be in the range 2 to 36. Spaces and tabs are ignored. The Text field is not case-sensitive.

If the radix is 16, a leading x or X or 0x or 0X, and an appended h or H, is disregarded. If the radix is 2, an appended b or B is disregarded. Other characters that do not belong to the number system generate an error.

### Syntax

\<emph\>text\</emph\> is the text to be converted. To differentiate between a hexadecimal number, such as A1 and the reference to cell A1, you must place the number in quotation marks, for example, "A1" or "FACE".

\<emph\>radix\</emph\> indicates the base of the number system. It may be any positive integer between 2 and 36.

### Example:

DECIMAL("17";10) returns 17.

DECIMAL("FACE";16) returns 64206.

DECIMAL("0101";2) returns 5.

\<bookmark_value\>DOLLAR function\</bookmark_value\>

## DOLLAR

Converts a number to an amount in the currency format, rounded to a specified decimal place. In the Value field enter the number to be converted to currency. Optionally, you may enter the number of decimal places in the Decimals field. If no value is specified, all numbers in currency format will be displayed with two decimal places.

You set the currency format in your system settings.

### Syntax

DOLLAR(value; decimals)

\<emph\>value\</emph\> is a number, a reference to a cell containing a number, or a formula which returns a number.

\<emph\>decimals\</emph\> is the optional number of decimal places.

### Example:

DOLLAR(255) returns $255.00. =DOLLAR(367.456;2) returns$367.46. Use the decimal separator that corresponds to the current locale setting.

\<bookmark_value\>EXACT function\</bookmark_value\>

## EXACT

Compares two text strings and returns TRUE if they are identical. This function is case-sensitive.

### Syntax

EXACT(text_1;text_2)

\<emph\>text_1\</emph\> refers to the first text to compare.

\<emph\>text_2\</emph\> is the second text to compare.

### Example:

EXACT("Sun microsystems";"Sun Microsystems") returns FALSE.

\<bookmark_value\>FIND function\</bookmark_value\>

## FIND

Returns the position of a string of text within another string.You can also define where to begin the search. The search term can be a number or any string of characters. The search is case-sensitive.

### Syntax

FIND(find_text; text; position)

\<emph\>find_text\</emph\> refers to the text to be found.

\<emph\>text\</emph\> is the text where the search takes place.

\<emph\>position\</emph\> (optional) is the position in the text from which the search starts.

### Example:

FIND(76;998877665544) returns 6.

\<bookmark_value\>FIXED function\</bookmark_value\>

## FIXED

Returns a number as text with a specified number of decimal places and optional thousands separators.

### Syntax

FIXED(Number; decimals; no thousands separators)

\<emph\>Number\</emph\> refers to the number to be formatted.

\<emph\>Decimals\</emph\> refers to the number of decimal places to be displayed.

NoThousandsSeparators (optional) determines whether the thousands separator is used. If the parameter is a number not equal to 0, the thousands separator is suppressed. If the parameter is equal to 0 or if it is missing altogether, the thousands separators of your current locale setting are displayed.

### Example:

FIXED(1234567.89;3) returns 1,234,567.890 as a text string.

FIXED(1234567.89;3;1) returns 1234567.890 as a text string.

\<bookmark_value\>IF function\</bookmark_value\>

## JIS

The JIS function converts half-width to full-width ASCII and katakana characters. Returns a text string.

See https://wiki.documentfoundation.org/Calc/Features/JIS_and_ASC_functions for a conversion table.

### Syntax

TRIM(Text)

Text is the text that contains characters to be converted.

\<bookmark_value\>LEFT function\</bookmark_value\>

## LEFT

Returns the first character or characters of a text.

### Syntax

LEFT(text; number)

\<emph\>text\</emph\> is the text where the initial partial words are to be determined.

\<emph\>Number\</emph\> (optional) specifies the number of characters for the start text. If this parameter is not defined, one character is returned.

### Example:

LEFT("output";3) returns \<emph\>out\</emph\>.

\<bookmark_value\>LEFT function\</bookmark_value\>

## LEFTB

Returns the first characters of a DBCS text.

### Syntax

LEFTB("Text"; Number_bytes)

Text is the text where the initial partial words are to be determined.

Number_bytes (optional) specifies the number of characters you want LEFTB to extract, based on bytes. If this parameter is not defined, one character is returned.

### Example:

LEFTB("中国";1) returns " " (1 byte is only half a DBCS character and a space character is returned instead).

LEFTB("中国";2) returns "中" (2 bytes constitute one complete DBCS character).

LEFTB("中国";3) returns "中 " (3 bytes constitute one DBCS character and a half; the last character returned is therefore a space character).

LEFTB("中国";4) returns "中国" (4 bytes constitute two complete DBCS characters).

LEFTB("office";3) returns "off" (3 non-DBCS characters each consisting of 1 byte).

\<bookmark_value\>LEN function\</bookmark_value\>

## LEN

Returns the length of a string including spaces.

### Syntax

LEN(text)

\<emph\>text\</emph\> is the text whose length is to be determined.

### Example:

LEN("Good Afternoon") returns \<emph\>14\</emph\>.

LEN(12345.67) returns \<emph\>8\</emph\>.

\<bookmark_value\>LEN function\</bookmark_value\>

## LENB

For double-byte character set (DBCS) languages, returns the number of bytes used to represent the characters in a text string.

### Syntax

LENB("Text")

\<emph\>text\</emph\> is the text whose length is to be determined.

### Example:

LENB("中") returns 2 (1 DBCS character consisting of 2 bytes).

LENB("中国") returns 4 (2 DBCS characters each consisting of 2 bytes).

LENB("office") returns 6 (6 non-DBCS characters each consisting of 1 byte).

=LENB("Good Afternoon") returns 14.

=LENB(12345.67) returns 8.

\<bookmark_value\>LOWER function\</bookmark_value\>

## LOWER

Converts all uppercase letters in a text string to lowercase.

### Syntax

LOWER(text)

\<emph\>text\</emph\> refers to the text to be converted.

### Example:

LOWER("Sun") returns sun.

\<bookmark_value\>MID function\</bookmark_value\>

## MID

Returns a text string of a text. The parameters specify the starting position and the number of characters.

### Syntax

MID(text; start; number)

\<emph\>text\</emph\> is the text containing the characters to extract.

\<emph\>start\</emph\> is the position of the first character in the text to extract.

\<emph\>number\</emph\> specifies the number of characters in the part of the text.

### Example:

MID("Sun Microsystems";5;5) returns \<emph\>Micro\</emph\>.

\<bookmark_value\>MID function\</bookmark_value\>

## MIDB

Returns a text string of a DBCS text. The parameters specify the starting position and the number of characters.

### Syntax

MIDB("Text"; Start; Number_bytes)

\<emph\>text\</emph\> is the text containing the characters to extract.

Start is the position of the first character in the text to extract.

Number_bytes specifies the number of characters MIDB will return from text, in bytes.

### Example:

MIDB("中国";1;0) returns "" (0 bytes is always an empty string).

MIDB("中国";1;1) returns " " (1 byte is only half a DBCS character and therefore the result is a space character).

MIDB("中国";1;2) returns "中" (2 bytes constitute one complete DBCS character).

MIDB("中国";1;3) returns "中 " (3 bytes constitute one and a half DBCS character; the last byte results in a space character).

MIDB("中国";1;4) returns "中国" (4 bytes constitute two complete DBCS characters).

MIDB("中国";2;1) returns " " (byte position 2 is not at the beginning of a character in a DBCS string; 1 space character is returned).

MIDB("中国";2;2) returns " " (byte position 2 points to the last half of the first character in the DBCS string; the 2 bytes asked for therefore constitutes the last half of the first character and the first half of the second character in the string; 2 space characters are therefore returned).

MIDB("中国";2;3) returns " 国" (byte position 2 is not at the beginning of a character in a DBCS string; a space character is returned for byte position 2).

MIDB("中国";3;1) returns " " (byte position 3 is at the beginning of a character in a DBCS string, but 1 byte is only half a DBCS character and a space character is therefore returned instead).

MIDB("中国";3;2) returns "国" (byte position 3 is at the beginning of a character in a DBCS string, and 2 bytes constitute one DBCS character).

MIDB("office";2;3) returns "ffi" (byte position 2 is at the beginning of a character in a non-DBCS string, and 3 bytes of a non-DBCS string constitute 3 characters).

\<bookmark_value\>PROPER function\</bookmark_value\>

## PROPER

Capitalizes the first letter in all words of a text string.

### Syntax

PROPER(text)

\<emph\>text\</emph\> refers to the text to be converted.

### Example:

PROPER("sun microsystems") returns Sun Microsystems.

\<bookmark_value\>REPLACE function\</bookmark_value\>

## REPLACE

Replaces part of a text string with a different text string. This function can be used to replace both characters and numbers (which are automatically converted to text). The result of the function is always displayed as text. If you intend to perform further calculations with a number which has been replaced by text, you will need to convert it back to a number using the VALUE function.

Any text containing numbers must be enclosed in quotation marks if you do not want it to be interpreted as a number and automatically converted to text.

### Syntax

REPLACE(text; position; length; new text)

\<emph\>Text\</emph\> refers to text of which a part will be replaced.

\<emph\>position\</emph\> refers to the position within the text where the replacement will begin.

\<emph\>length\</emph\> is the number of characters in \<emph\>text\</emph\> to be replaced.

\<emph\>new text\</emph\> refers to the text which replaces \<emph\>text\</emph\>.

### Example:

REPLACE("1234567";1;1;"444") returns "444234567". One character at position 1 is replaced by the complete \<emph\>new text\</emph\>.

\<bookmark_value\>REPT function\</bookmark_value\>

## REPT

Repeats a character string by the given number of copies.

### Syntax

REPT(text; number)

\<emph\>text\</emph\> is the text to be repeated.

\<emph\>number\</emph\> is the number of repetitions.

The result can be a maximum of 255 characters.

### Example:

REPT("Good morning"; 2) returns \<emph\>Good morningGood morning\</emph\>.

\<bookmark_value\>RIGHT function\</bookmark_value\>

## RIGHT

Returns the last character or characters of a text.

### Syntax

RIGHT(text; number)

\<emph\>text\</emph\> is the text of which the right part is to be determined.

\<emph\>number\</emph\> (optional) is the number of characters from the right part of the text.

### Example:

RIGHT("Sun";2) returns \<emph\>un\</emph\>.

\<bookmark_value\>RIGHT function\</bookmark_value\>

## RIGHTB

Returns the last character or characters of a text with double bytes characters sets (DBCS).

### Syntax

RIGHTB("Text"; Number_bytes)

Text is the text of which the right part is to be determined.

Number_bytes (optional) specifies the number of characters you want RIGHTB to extract, based on bytes.

### Example:

RIGHTB("中国";1) returns " " (1 byte is only half a DBCS character and a space character is returned instead).

RIGHTB("中国";2) returns "国" (2 bytes constitute one complete DBCS character).

RIGHTB("中国";3) returns " 国" (3 bytes constitute one half DBCS character and one whole DBCS character; a space is returned for the first half).

RIGHTB("中国";4) returns "中国" (4 bytes constitute two complete DBCS characters).

RIGHTB("office";3) returns "ice" (3 non-DBCS characters each consisting of 1 byte).

\<bookmark_value\>ROMAN function\</bookmark_value\>

## ROMAN

Converts a number into a Roman numeral. The value range must be between 0 and 3999, the modes can be integers from 0 to 4.

### Syntax

ROMAN(Number; Mode)

\<emph\>Number\</emph\> is the number that is to be converted into a Roman numeral.

\<emph\>Mode\</emph\> (optional) indicates the degree of simplification. The higher the value, the greater is the simplification of the Roman number.

### Example:

ROMAN(999) returns CMXCIX

ROMAN(999;0) returns CMXCIX

ROMAN (999;1) returns LMVLIV

ROMAN(999;2) returns XMIX

ROMAN(999;3) returns VMIV

ROMAN(999;4) returns IM

\<bookmark_value\>SEARCH function\</bookmark_value\>

## SEARCH

Returns the position of a text segment within a character string. You can set the start of the search as an option. The search text can be a number or any sequence of characters. The search is not case-sensitive.

The search supports regular expressions. You can enter "all.*", for example to find the first location of "all" followed by any characters. If you want to search for a text that is also a regular expression, you must precede every character with a \ character. You can switch the automatic evaluation of regular expression on and off in - LibreOffice Calc - Calculate.

### Syntax

SEARCH(find_text; text; position)

\<emph\>find_text\</emph\> is the text to be searched for.

\<emph\>text\</emph\> is the text where the search will take place.

\<emph\>position\</emph\> (optional) is the position in the text where the search is to start.

### Example:

SEARCH(54;998877665544) returns 10.

\<bookmark_value\>SUBSTITUTE function\</bookmark_value\>

## SUBSTITUTE

Substitutes new text for old text in a string.

### Syntax

SUBSTITUTE(text; search_text; new text; occurrence)

\<emph\>text\</emph\> is the text in which text segments are to be exchanged.

\<emph\>search_text \</emph\>is the text segment that is to be replaced (a number of times).

\<emph\>new text\</emph\> is the text that is to replace the text segment.

\<emph\>occurrence\</emph\> (optional) indicates which occurrence of the search text is to be replaced. If this parameter is missing the search text is replaced throughout.

### Example:

SUBSTITUTE("123123123"; "3"; "abc") returns \<emph\>12abc12abc12abc\</emph\>.

SUBSTITUTE("123123123"; "3"; "abc"; 2) returns \<emph\>12312abc123\</emph\>.

\<bookmark_value\>T function\</bookmark_value\>

## T

This function returns the target text, or a blank text string if the target is not text.

### Syntax

T(value)

If \<emph\>value\</emph\> is a text string or refers to a text string, T returns that text string; otherwise it returns a blank text string.

### Example:

T(12345) returns an empty string "".

T("12345") returns the string 12345.

\<bookmark_value\>TEXT function\</bookmark_value\>

## TEXT

Converts a number into text according to a given format.

### Syntax

TEXT(Number; Format)

\<emph\>Number\</emph\> is the numerical value to be converted.

\<emph\>Format\</emph\> is the text which defines the format. Use decimal and thousands separators according to the language set in the cell format.

### Example:

=TEXT(12.34567;"###.##") returns the text 12.35

=TEXT(12.34567;"000.00") returns the text 012.35

\<bookmark_value\>TRIM function\</bookmark_value\>

## TRIM

Removes spaces from a string, leaving only a single space character between words.

### Syntax

TRIM(Text)

Text refers to text in which spaces are to be removed.

### Example:

=TRIM(" hello world ") returns hello world without leading and trailing spaces and with single space between words.

\<bookmark_value\>CHAR function\</bookmark_value\>

## UNICHAR

Converts a code number into a Unicode character or letter.

UNICHAR(number)

### Example: \<bookmark_value\>CODE function\</bookmark_value\>

## UNICODE

Returns the numeric code for the first Unicode character in a text string.

UNICODE("Text")

### Example: \<bookmark_value\>UPPER function\</bookmark_value\>

## UPPER

Converts the string specified in the text field to uppercase.

### Syntax

UPPER(text)

\<emph\>text\</emph\> refers to the lower case letters you want to convert to upper case.

### Example:

UPPER("Good Morning") returns GOOD MORNING.

\<bookmark_value\>VALUE function\</bookmark_value\>

## VALUE

Converts a text string into a number.

### Syntax

VALUE(text)

\<emph\>text\</emph\> is the text to be converted to a number.

### Example:

VALUE("4321") returns 4321.