Text Functions

This section contains descriptions of the Text functions.

このコマンドの見つけ方

挿入 → 関数 → カテゴリー テキスト


Using double quotation marks in formulas

To include a text string in a formula, place the text string between two double quotation marks (") and Calc takes the characters in the string without attempting to interpret them. For example, the formula ="Hello world!" displays the text string Hello world! in the cell, with no surrounding double quotation marks.

The more complex formula =CONCATENATE("Life is really simple, "; "but we insist on making it complicated "; "(Confucius).") concatenates three individual strings in double quotation marks, outputting Life is really simple, but we insist on making it complicated (Confucius).

To place a literal double quotation mark within a string inside a formula, two methods can be used:

  1. You can "escape" the double quotation mark with an additional double quotation mark, and Calc treats the escaped double quotation mark as a literal value. For example, the formula ="My name is ""John Doe""." outputs the string My name is "John Doe". Another simple example is the formula =UNICODE("""") which returns 34, the decimal value of the Unicode quotation mark character (U+0022) — here the first and fourth double quotation marks indicate the beginning and end of the string, while the second double quotation mark escapes the third.

  2. You can use the CHAR function or the UNICHAR function to insert a double quotation mark. For example, the formula =UNICHAR(34) & "The Catcher in the Rye" & UNICHAR(34) & " is a famous book by J. D. Salinger." displays the string "The Catcher in the Rye" is a famous book by J. D. Salinger.

Be aware that Calc's AutoCorrect function may modify double quotation marks. AutoCorrect should not change the double quotation marks within formula cells but may change those used in non-formula cells containing text. For example, if you copy a string that is surrounded by some other form of typographical double quotation marks, such as the left double quotation mark (U+201C) and the right double quotation mark (U+201D), and then paste into a formula cell, an error may result. Open the Double Quotes area of the Tools - AutoCorrect Options - Localized Options dialog to set the characters used to automatically correct the start and end typographical double quotation marks. Uncheck the Replace toggle button to disable the feature.

ARABIC

Returns the numeric value corresponding to a Roman number expressed as text.

ASC

Converts double-byte (full-width) characters to single-byte (half-width) ASCII and katakana characters.

JIS

Converts single-byte (half-width) ASCII or katakana characters to double-byte (full-width) characters.

REGEX

Matches and extracts or optionally replaces text using regular expressions.

ROMAN

Converts a number into a Roman numeral. The value range must be between 0 and 3999. A simplification mode can be specified in the range from 0 to 4.

VALUE

Converts the string representation of a number to numeric form. If the supplied string is a valid date, time, or date-time, the corresponding date-time serial number is returned.

WEBSERVICE

Get some web content from a URI.

FILTERXML

Apply a XPath expression to a XML document.

ENCODEURL

Returns a URL-encoded string.

BAHTTEXT

数値を、タイの通貨名を含むタイ語のテキストに変換します。

Syntax

BAHTTEXT(数値)

数値 は任意の数字です。数値の整数部に「バーツ」が追加され、数値の小数部に「サタン」が追加されます。

Example

=BAHTTEXT(12.65) は、「12 バーツ 65 サタン」を意味するタイ文字の文字列を返します。

Technical information

This function is not part of the Open Document Format for Office Applications (OpenDocument) Version 1.3. Part 4: Recalculated Formula (OpenFormula) Format standard. The name space is

COM.MICROSOFT.BAHTTEXT

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

BASE(Number; Radix [; MinimumLength])

数値 は、変換される正の整数です。

Radix indicates the base of the numeral system. It may be any positive integer between 2 and 36.

最小長さ (オプション) は、作成された文字列の最小長さを決定します。指定した最小長さより短い結果には、左にゼロが追加されます。

Example

=BASE(17;10;4) は、10 進数の 0017 を返します。

=BASE(17;2) は、2 進数の 10001 を返します。

=BASE(255;16;4) は、16 進数の 00FF を返します。

See also

DECIMAL

CHAR

現在のロケールの文字コード表に従って、数値を文字に変換します。数値は 2 桁または 3 桁の整数の数値です。

127 より大きいコードは、iso-8859-1、iso-8859-2、Windows-1252、Windows-1250 など、システムの文字マッピングに依存する可能性があり、移植性がないことがあります。

Syntax

CHAR(数値)

数値 は、文字のコード値を表す 1 から 255 の数値です。

Example

=CHAR(100) は、文字 d を返します。

="abc" & CHAR(10) & "def" 文字列に改行文字を挿入します。

CLEAN

文字列から印刷されない文字を削除します。

Syntax

CLEAN("テキスト")

テキスト は、印刷できないすべての文字を削除するテキストを指します。

Example

=LEN(CLEAN(CHAR(7) & "LibreOffice Calc" & CHAR(8))) returns 16, showing that the CLEAN function removes the non-printable Unicode U+0007 ("BEL") and U+0008 ("BS") characters at the beginning and end of the string argument. CLEAN does not remove spaces.

CODE

テキストや文字列の先頭文字のコードを返します。

Syntax

CODE("テキスト")

テキスト は、先頭文字のコード番号を調べるテキストです。

127 より大きいコードは、iso-8859-1、iso-8859-2、Windows-1252、Windows-1250 など、システムの文字マッピングに依存する可能性があり、移植性がないことがあります。

Example

=CODE("Hieronymus") は 72 を返します。=CODE("hieroglyphic") は 104 を返します。

note

ここで使用されるコードは ASCII コードではなく、現在使用しているコード表のコードです。


CONCATENATE

複数の文字列を 1 つのテキスト文字列に結合します。

Syntax

CONCATENATE(String 1 [; String 2 [; … [; String 255]]])

String 1[; String 2][; … ;[String 255]] are strings or references to cells containing strings.

Example

=CONCATENATE("Good ";"Morning ";"Mrs. ";"Doe") は、Good Morning Mrs. Doe を返します。

DECIMAL

Converts text that represents a number in a numeral system with the given base radix to a positive integer. 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, are disregarded. If the radix is 2, an appended b or B is disregarded. Other characters that do not belong to the numeral system generate an error.

Syntax

DECIMAL("テキスト"; 基数)

Text is the text to be converted.

Radix indicates the base of the numeral system. It may be any positive integer between 2 and 36.

Example

=DECIMAL("17";10) は、17 を返します。

=DECIMAL("FACE";16) は、64206 を返します。

=DECIMAL("0101";2) は、5 を返します。

See also

BASE

DOLLAR

Converts a number to a string representing the amount in the currency format, rounded to a specified decimal places, using the decimal separator that corresponds to the current locale setting. In the Value field enter the number to be converted. 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.

自分のシステム設定に通貨書式を設定します。

Syntax

DOLLAR(Value [; Decimals])

は、数値、数値を含むセルへの参照、または数値を返す数式です。

小数 は、小数点以下の桁数 (オプション) です。

Example

=DOLLAR(255) returns $255.00 for the English (USA) locale and USD (dollar) currency; ¥255.00 for the Japanese locale and JPY (yen) currency; or 255,00 € for the German (Germany) locale and EUR (euro) currency.

=DOLLAR(367.456;2) returns $367.46.

EXACT

2 つのテキスト文字列を比較して、同じであれば TRUE を返します。この関数は、大文字と小文字を区別します。

Syntax

EXACT("テキスト 1"; "テキスト 2")

テキスト 1 は、比較する最初のテキストを指します。

テキスト 2 は、比較する 2 番目のテキストです。

Example

=EXACT("microsystems";"Microsystems") は、FALSE を返します。

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("FindText"; "Text" [; Position])

検索テキスト は、検索されるテキストを指します。

テキスト は、検索を実行するテキストです。

位置 (オプション) は、検索を開始するテキスト内の位置です。

Example

=FIND(76;998877665544) は、6 を返します。

FIXED

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

Syntax

FIXED(Number; [Decimals = 2 [; NoThousandsSeparators = FALSE]])

Number is rounded to Decimals places (after the decimal separator) and the result formatted as text, using locale-specific settings.

Decimals (optional) refers to the number of decimal places to be displayed. If Decimals is negative, Number is rounded to ABS(Decimals) places to the left from the decimal point. If Decimals is a fraction, it is truncated actually ignoring what is the closest integer.

NoThousandsSeparators (optional) determines whether the thousands separator is used. If it is TRUE or non-zero, then group separators are omitted from the resulting string. 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) は、テキスト文字列として 1,234,567.890 を返します。

=FIXED(123456.789;;TRUE) returns 123456.79 as a text string.

=FIXED(12345.6789;-2) returns 12,300 as a text string.

=FIXED(12134567.89;-3;1) returns 12135000 as a text string.

=FIXED(12345.789;3/4) returns 12,346 as a text string.

=FIXED(12345.789;8/5) returns 12,345.8 as a text string.

LEFT

テキストの先頭の文字 (複数の文字も可) を返します。

Syntax

LEFT("Text" [; Number])

テキスト は、最初の部分ワードが決定されるテキストです。

文字数 (オプション) は、テキストの左 (先頭) から取り出す文字数です。このパラメーターが指定されていない場合、テキストの一番左 (先頭) の文字だけを返します。

Example

=LEFT("output";3) は、「out」を返します。

LEFTB

Returns the first characters of a DBCS text.

tip

この関数はLibreOffice 4.2以降で利用できます。


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).

LEN

この関数は、文字列の長さを返します。スペースも文字とみなされます。

Syntax

LEN("テキスト")

テキスト は、その長さが決定されるテキストです。

Example

=LEN("Good Afternoon") は、14 を返します。

=LEN(12345.67) は、8 を返します。

LENB

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

tip

この関数はLibreOffice 4.2以降で利用できます。


Syntax

LENB("テキスト")

テキスト は、その長さが決定されるテキストです。

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") は、14 を返します。

=LENB(12345.67) は、8 を返します。

LOWER

文字列のアルファベット文字を、すべて小文字に変換します。

Syntax

LOWER("テキスト")

テキスト は、変換されるテキストを指します。

Example

=LOWER("Sun") は、sun を返します。

MID

テキストの文字列を返します。パラメーターは、開始位置と文字数を返します。

Syntax

MID("テキスト"; 開始; 数値)

テキスト は、抽出する文字を含むテキストです。

開始 は、抽出する文字の最初の文字の位置です。

数値 は、テキストの一部の文字数を指定します。

Example

=MID("office";2;2) は、ff を返します。

MIDB

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

tip

この関数はLibreOffice 4.2以降で利用できます。


Syntax

MIDB("Text"; Start; Number_bytes)

テキスト は、抽出する文字を含むテキストです。

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).

PROPER

テキスト文字列内にあるすべての単語の最初の文字を大文字にします。

Syntax

PROPER("テキスト")

テキスト は、変換されるテキストを指します。

Example

=PROPER("the document foundation") returns The Document Foundation.

REPLACE

この関数は、文字列の一部を、別の文字列に置き換えます。文字列または数値の一部分を置換します。結果は常に文字列で返るため、数値は自動的に文字列としての数に変換されます。置換された数値を計算に使うには、戻り値を VALUE 関数で数値に変換する必要があります。

数値として認識されたくない(つまり、自動的にテキストに変換してもかまわない)数字を含むテキストは引用符で囲みます。

Syntax

REPLACE("テキスト"; 位置; 長さ; "新しいテキスト")

文字列 は、その一部が置換されるテキストです。

位置 は、置換を開始するテキスト内の位置を指します。

長さ は、テキスト 内の置換される文字数です。

新しいテキスト は、テキストを置換するテキストを指します。

Example

=REPLACE("1234567";1;1;"444") は、"444234567" を返します。位置 1 の 1 文字は、完全な新しいテキストに置換されます。

REPT

指定された だけ文字列を繰り返します。

Syntax

REPT("テキスト"; 数値)

テキスト は、繰り返されるテキストです。

数値 は、繰り返し回数です。

Example

=REPT("Good morning";2) は、Good morningGood morning を返します。

tip

Refer to the REPT wiki page for more details about this function.


RIGHT

テキストの最後の文字 (複数の文字も可) を返します。

Syntax

RIGHT("Text" [; Number])

テキスト は、右部分が決定されるテキストです。

Number (optional) is the number of characters from the right part of the text. If this parameter is not defined, one character is returned.

Example

=RIGHT("Sun";2) は、un を返します。

RIGHTB

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

tip

この関数はLibreOffice 4.2以降で利用できます。


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. If this parameter is not defined, one byte is returned.

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).

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. If the text is not found, returns error 519 (#VALUE).

The search supports wildcards or regular expressions. With regular expressions enabled, 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 either precede every regular expression metacharacter or operator with a "\" character, or enclose the text into \Q...\E. You can switch the automatic evaluation of wildcards or regular expression on and off in - LibreOffice Calc - Calculate.

warning

When using functions where one or more arguments are search criteria strings that represents a regular expression, the first attempt is to convert the string criteria to numbers. For example, ".0" will convert to 0.0 and so on. If successful, the match will not be a regular expression match but a numeric match. However, when switching to a locale where the decimal separator is not the dot makes the regular expression conversion work. To force the evaluation of the regular expression instead of a numeric expression, use some expression that can not be misread as numeric, such as ".[0]" or ".\0" or "(?i).0".


Syntax

SEARCH("FindText"; "Text" [; Position])

検索テキスト は、検索されるテキストです。

テキスト は、検索を実行するテキストです。

位置 (オプション) は、検索を開始するテキスト内の位置です。

Example

=SEARCH(54;998877665544) は、10 を返します。

SUBSTITUTE

文字列内の古いテキストを新しいテキストで置換します。

Syntax

SUBSTITUTE("Text"; "SearchText"; "NewText" [; Occurrence])

テキスト は、テキストセグメントが交換されるテキストです。

検索テキスト は、指定回数、置換されるテキストセグメントです。

新しいテキスト は、テキストセグメントを置換するテキストです。

置換文字列 (オプション) は、検索テキストが置換される置換対象を示します。このパラメーターがない場合は、検索テキストが最初から最後まで置換されます。

Example

=SUBSTITUTE("123123123";"3";"abc") は、12abc12abc12abc を返します。

=SUBSTITUTE("123123123";"3";"abc";2) は、12312abc123 を返します。

T

この関数は、ターゲットテキストを返します。ターゲットがテキストでない場合は、空白の文字列を返します。

Syntax

T(値)

がテキスト文字列またはテキスト文字列を参照する場合、T はテキスト文字列を返します。そのほかの場合は、空白のテキスト文字列を返します。

Example

=T(12345) は、空の文字列を返します。

=T("12345") は、文字列 12345 を返します。

TEXT

Converts a value into text according to a given format.

Syntax

TEXT(Value; Format)

Value is the value (numerical or textual) to be converted.

書式 は、書式を定義するテキストです。小数位と桁の区切りはセル書式に設定されている言語に従います。

Example

=TEXT(12.34567;"###.##") は、テキスト 12.35 を返します。

=TEXT(12.34567;"000.00") は、テキスト 012.35 を返します

=TEXT("xyz";"=== @ ===") returns the text === xyz ===

tip

See also Number format codes: custom format codes defined by the user.


TRIM

文字列の間に空白文字を 1 文字分だけ残し、文字列から空白を削除します。

Syntax

TRIM("テキスト")

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.

UNICHAR

コード番号をユニコードキャラクターか文字に変換します。

Syntax

UNICHAR(number)

Example

=UNICHAR(169) はコピーライト記号である©を返します。

tip

See also the UNICODE() function.


UNICODE

文字列の先頭文字のユニコードを返します。

Syntax

UNICODE("Text")

Example

=UNICODE("©") はユニコードでコピーライト記号を示す 169 を返します。

tip

See also the UNICHAR() function.


UPPER

テキスト フィールドに含まれるアルファベット文字を、すべて大文字に変換します。

Syntax

UPPER("テキスト")

テキスト は、大文字に変換する小文字を指します。

Example

=UPPER("Good Morning") は、GOOD MORNING を返します。

ご支援をお願いします!