Text Functions

This section contains descriptions of the Text functions.

Så här använder du det här kommandot...

Infoga - Funktion - Kategori Text


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

Konverterar ett tal till thaitext, inklusive valutanamnen för thai.

Syntax

BAHTTEXT(Siffra)

Tal är ett valfritt tal. "Baht" läggs till i heltalsdelen och "Satang" läggs till i decimaldelen.

Example

=BAHTTEXT(12.65) returnerar en sträng med thailändska tecken som betyder "Tolv baht och sextiofem satang".

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

BAS

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

Tal är det positiva heltal som ska omvandlas.

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

Minimilängd (valfritt) anger minimilängd för teckensekvensen som skapats. Om texten är kortare än den angivna minimilängden, läggs nollor till vänster om strängen.

Example

=BAS(17;10;4) returnerar 0017 i decimalsystemet.

=BAS(17;2) returnerar 10001 i det binära systemet.

=BAS(255;16;4) returnerar 00FF i hexadecimalsystemet.

See also

DECIMAL

BYT.UT

Ersätter text med ny text.

Syntax

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

Text är texten vars textsegment ska ändras.

Söktextär det textsegment som ska ersättas (ett antal gånger).

Nytext är texten som ska ersätta textsegmentet.

Förekomst (valfritt) anger vilken förekomst av söktexten som ska ersättas. Om den här parametern saknas ersätts söktexten helt och hållet.

Example

=BYT.UT("123123123";"3";"abc") returnerar 12abc12abc12abc.

=BYT.UT("123123123";"3";"abc";2) returnerar 12312abc123.

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"; Bas)

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

=DECIMAL("ANSIKTE";16) returnerar 64206.

=DECIMAL("0101";2) returnerar 5.

See also

BASE

ERSÄTT

Ersätter en del av en textsträng med en annan textsträng. Du kan använda den här funktionen om du vill ersätta både tecken och tal (som automatiskt omvandlas till text). Resultatet av den här funktionen visas alltid som text. Om du tänker utföra fler beräkningar med ett tal som har ersatts med text, måste du konvertera tillbaka det till ett tal med hjälp av funktionen TEXTNUM.

All text som innehåller siffror måste skrivas inom citattecken om du inte vill att texten ska tolkas som ett numeriskt värde och konverteras till text.

Syntax

ERSÄTT("Text"; Position; Längd; "Nytext")

Text refererar till en textsträng där ersättningen kommer att ske.

Position hänvisar till positionen i texten där ersättningen börjar.

Längd är antalet tecken i Text som ska ersättas.

Nytext hänvisar till den som ersätter Text.

Example

=ERSÄTT("1234567";1;1;"444") returnerar "444234567". Ett tecken i position 1 ersätts av en fullständig Nytext.

EXAKT

Jämför två textsträngar och returnerar SANT om de är identiska. Funktionen är versalkänslig.

Syntax

EXAKT("Text1"; "Text2")

Text1 hänvisar till den första texten som ska jämföras.

Text2 är den andra texten som ska jämföras.

Example

=EXAKT("microsystems";"Microsystems") returnerar FALSKT.

EXTEXT

Returnerar en textsträng från en text. Parametrarna anger startpositionen och antalet tecken.

Syntax

EXTEXT("Text"; Start; Tal)

Text är texten som innehåller tecken som ska hämtas.

Start är det första tecknets position i texten som du vill ta fram.

Tal anger antalet tecken i textdelen.

Example

=MID("office";2;2) returnerar ff.

FASTTAL

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

=FASTTAL(1234567.89;3) returnerar 1,234,567.890 som en textsträng.

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

GEMENER

Konverterar alla stora bokstäver (versaler) i en textsträng till små bokstäver (gemener).

Syntax

GEMENER("Text")

Text hänvisar till texten som ska konverteras.

Example

=GEMENER("Sun";2) returnerar sun.

HITTA

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

Hittatext hänvisar till texten som eftersöks.

Text är texten där sökningen utförs.

Position (valfritt) är positionen i texten där sökningen ska starta.

Example

=HITTA(76;998877665544) returnerar 6.

HÖGER

Returnerar det sista tecknet eller tecknen i en text.

Syntax

RIGHT("Text" [; Number])

Text är den text från vilken högra delen ska bestämma.

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

=HÖGER("Sun";2) returnerar Sun.

INITIAL

Gör om första bokstaven i alla ord i en textsträng till versaler.

Syntax

INITIAL("Text")

Text hänvisar till texten som ska konverteras.

Example

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

KOD

Returnerar en numerisk kod för det första tecknet i en textsträng.

Syntax

KOD("Text")

Text är den text som ska genomsökas efter koden för det första tecknet.

Koder större än 127 kan vara beroende av systemets teckenmappning (t.ex. iso-8859-1, iso-8859-2, Windows-1252, Windows-1250) och är kanske inte portabla.

Example

=KOD("Hieronymus") returnerar 72, =KOD("hieroglyphic") returnerar 104.

note

Den här koden är inte ASCII-koden, utan den aktuella kodtabellens kod.


LEFTB

Returnerar det första tecknet i en DBCS-text.

tip

This function is available since 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).

LENB

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

tip

This function is available since LibreOffice 4.2.


Syntax

LENB("Text")

Text är texten vars längd ska anges.

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.

LÄNGD

Returnerar längden på en sträng inklusive blanksteg.

Syntax

LÄNGD("Text")

Text är texten vars längd ska anges.

Example

=LÄNGD("God kväll") returnerar 14.

=LÄNGD(12345,67) returnerar 8.

MIDB

Returnerar en textsträng från en DBCS-text. Parametrarna anger startpositionen och antalet tecken.

tip

This function is available since LibreOffice 4.2.


Syntax

MIDB("Text"; Start; Number_bytes)

Text är texten som innehåller tecken som ska hämtas.

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

RENSA

Tar bort mellanslag från en sträng, lämnar endast ett mellanslagstecken mellan ord.

Syntax

RENSA("Text")

Text refererar till text i vilken mellanrum ska tas bort.

Example

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

REP

Upprepar en teckensträng antal gånger.

Syntax

REP("Text"; Tal)

Text är texten som ska upprepas.

Tal är antalet upprepningar.

Example

=REP("God morgon";2) returnerar God morgonGod morgon.

tip

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


RIGHTB

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

tip

This function is available since 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).

SAMMANFOGA

Kombinerar flera textsträngar till en sträng.

Syntax

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

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

Example

=SAMMANFOGA("God ";"morgon ";"Fru ";"Dahlström") returnerar: God morgon, fru Dahlström.

STÄDA

Alla icke utskrivbara tecken tas bort från strängen.

Syntax

STÄDA("Text")

Text hänvisar till den text du vill ta bort alla tecken som inte går att skriva ut.

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.

SÖK

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

Sökningen stöder jokertecken eller reguljära uttryck. Med reguljära uttryck aktiverat, kan du skriva "all.*", för att hitta första platsen för "all" följt av vilka bokstäver som helst (eller inga). Om du vill söka efter en text som också är ett reguljärt uttryck, anger du "\"-tecknet (bakstreck), eller omger texten med \Q...\E. Du kan stänga av eller aktivera automatisk evaluering av jokertecken och reguljära uttryck i inställningarna under - LibreOffice Calc - Beräkna.

warning

Att använda funktioner där ett eller flera argument är sök-kritierier som representerar reguljära uttryck, ger ett första försök att konvertera söksträngen till ett tal. Till exempel, ".0" konverteras till 0.0 och så vidare. Om det lyckas så gör ett försök att matcha numeriskt istället för strängbaserat. Men om en locale används där decimalskiljetecknet inte är punkt kommer det att evalueras som reguljärt uttryck. För att tvinga en matchning som strängbaserat reguljärt uttryck istället för numeriskt som ett tal kan du använda något som inte kan tolkas som ett tal, till exmpel ".[0]", ".\0" eller "(?i).0".


Syntax

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

Hittatext är texten som ska sökas.

Text är texten där sökningen utförs.

Position (valfritt) är positionen i texten där sökningen ska starta.

Example

=SÖK(54;998877665544) returnerar 10.

T

Funktionen returnerar måltexten, eller en tom textsträng om målet inte är text.

Syntax

T(Värde)

Om Värde är en textsträng som hänvisar till en textsträng returnerar T den textsträngen, annars returneras en tom textsträng.

Example

=T(12345) returnerar en tom sträng.

=T("12345") returnerar strängen 12345.

TECKENKOD

Konverterar ett tal till tecken enligt den aktuella kodtabellen. Talet kan bestå av en eller två siffror.

Koder större än 127 kan vara beroende av systemets teckenmappning (t.ex. iso-8859-1, iso-8859-2, Windows-1252, Windows-1250) och är kanske inte portabla.

Syntax

TECKENKOD(tal)

Tal är talet mellan 1 och 255 som representerar tecknets kodvärde.

Example

=¨TECKENKOD(100) returnerar tecknet d.

="abc", TECKENKOD(10) och "def" infogar en radmatning i strängen.

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.

Format är den text som definierar formatet. Använd decimaler och tusentalsavgränsare enligt språkinställningarna i cellformatet.

Example

=TEXT(12,34567;"###,##") returnerar texten 12,35

=TEXT(12,34567;"000,00") returnerar texten 012,35

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

tip

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


UNICHAR

Omvandlar ett kodtal till ett Unicode-tecken eller en Unicode-bokstav.

Syntax

UNICHAR(number)

Example

=UNICHAR(169) returnerar copyrighttecknet (c).

tip

See also the UNICODE() function.


UNICODE

Returnerar koden för det första Unicode-tecknet i en text.

Syntax

UNICODE("Text")

Example

=UNICODE("(c)") returnerar Unicode-talet 169 för copyrighttecknet.

tip

See also the UNICHAR() function.


VALUTA

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.

Du anger valutaformatet i systeminställningarna.

Syntax

DOLLAR(Value [; Decimals])

Värde är ett nummer, en referens till en cell som innehåller ett nummer eller en formel som returnerar ett nummer.

Decimaler är det valfria numret för decimaler.

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.

VERSALER

Konverterar den sträng som anges i fältet text till versaler.

Syntax

VERSALER("Text")

Text hänvisar till de gemener du vill konvertera till versaler.

Example

=VERSALER("God morgon") returnerar GOD MORGON.

VÄNSTER

Returnerar det första tecknet eller tecknen i en text.

Syntax

LEFT("Text" [; Number])

Text är texten där de initiala partiella orden ska anges.

Antal (valfritt) anger antalet tecken för starttexten. Om parametern saknas returneras ett (1) tecken.

Example

=VÄNSTER("utdata";3) returnerar "ut".

Stötta oss!