ID EN
#Dynamic array

TEXTBEFORE

Excel Functions 🇮🇩 Bahasa Indonesia

Ekstrak teks sebelum pembatas

Syntax

EXCEL
=TEXTBEFORE(text, delimiter, [instance_num], [match_mode], [match_end], [if_not_found])

Arguments

Parameter Deskripsi
text The text string to extract from.
delimiter The character(s) that delimit the text.
instance_num [optional] The instance of the delimiter in text. Default is 1.
match_mode [optional] Case-sensitivity. 0 = enabled, 1 = disabled. Default is 0.
match_end [optional] Treat end of text as delimiter. 0 = disabled, 1 = enabled. Default is 0.
if_not_found [optional] Value to return when no match is found. #N/A is default.

Return Value

String teks yang diekstraksi

Details

Fungsi TEXTBEFORE mengekstrak teks yang muncul sebelum pembatas tertentu. Ketika beberapa pembatas muncul dalam teks, TEXTBEFORE dapat mengembalikan teks sebelum kemunculan pembatas yang ke-n. TEXTBEFORE juga dapat mengekstrak teks yang muncul sebelum pembatas tertentu saat menghitung dari akhir string teks (yaitu, mendapatkan teks sebelum pembatas kedua hingga terakhir). Perhatikan bahwa Excel memiliki tiga fungsi terkait yang memisahkan teks: Untuk mengekstrak teks yang muncul sebelum karakter atau substring tertentu, sediakan teks dan karakter yang akan digunakan sebagai pembatas dalam tanda kutip ganda (""). Misalnya, untuk mengekstrak nama belakang dari "Jones, Bob", berikan koma dalam tanda kutip ganda (",") sebagai pembatas: Perhatikan bahwa Anda dapat menggunakan lebih dari satu karakter untuk pembatas. Misalnya untuk mengekstrak dimensi pertama

Contoh

Basic usage

To extract the text that occurs before a specific character or substring, provide the text and the character(s) to use for delimiter in double quotes

EXCEL
=TEXTBEFORE("Jones,Bob",",") // returns "Jones"
Basic usage

Note that you can use more than one character for delimiter. For example to extract the first dimension in the text string "12 ft x 20 ft", use " x "f

EXCEL
=TEXTBEFORE("12 ft x 20 ft"," x ") // returns "12 ft"
Text before with a positive instance number

The formulas below extract text before the first and second occurrence of a hyphen character ("-"):

EXCEL
=TEXTBEFORE("ABX-112-Red-Y","-",1) // returns "ABX"
=TEXTBEFORE("ABX-112-Red-Y","-",2 // returns "ABX-112"
Text before with a negative instance number

The formulas below extract the text that occurs before the last hyphen and the second to the last hyphen:

EXCEL
=TEXTBEFORE("ABX-112-Red-Y","-",-1) // returns "ABX-112-Red"
=TEXTBEFORE("ABX-112-Red-Y","-",-2) // returns "ABX-112"
Match end of text

Normally, TEXTBEFORE does not treat the end of a text string as a delimiter. For example, by default, the formula below will return #N/A because there

EXCEL
=TEXTBEFORE("ABX-123-Red-XYZ","-",4) // returns #N/A
Match end of text

If we enable match_end by providing 1, the formula behaves as if a delimiter exists after "XYZ":

EXCEL
=TEXTBEFORE("ABX-123-Red-XYZ","-",4,,1) // returns "ABX-123-Red-XYZ"

See Also

TEXTJOIN TEXTSPLIT TEXTAFTER CONCAT