Returns a section of a string starting at a given character and up to a specified number of bytes. Learn more.
The MIDB function in Google Sheets is used to extract a portion of a text string, starting at a specific character position, and for a given length in bytes.
This function is useful when working with multi-byte character encodings, such as UTF-8, where some characters may require more than one byte to represent.
The syntax of the MIDB function is as follows:
MIDB(string, startingat, extractlength_bytes)
string: This is the text string from which you want to extract a portion.
starting_at: It specifies the character position in the string where the extraction should begin. The first character is at position 1.
extractlengthbytes: This indicates the number of bytes to extract from the string, starting from the specified position.
Here's an example to demonstrate the usage of MIDB:
=MIDB("Hello, 世界!", 8, 6)
In this example, the string "Hello, 世界!" contains a mix of English and Chinese characters.
The function MIDB extracts 6 bytes starting from the 8th character position, resulting in the output "世界!" which means "world" in Chinese.
Please note that the MIDB function works with byte positions, not character positions, so it's important to be aware of the specific encoding of the text string you're working with to ensure accurate extraction.