Documentation/Calc Functions/SEARCHB/en

Function name:
SEARCHB

Category:
Text

Summary:
Uses a case-insensitive match to find the start byte of one text string within another text string. Each string may contain both single-byte and double-byte characters.

Syntax:
SEARCHB(FindText; Text[; Position])

Returns:
Returns a positive integer which is the position of the first byte of the first occurrence of the string to be found, within the string to be searched. The value returned cannot be greater than the length (in bytes) of the string to be searched.

Arguments:
Find Text is a text string (in quotation marks), a number, or a reference to a cell containing one of those types, that is the string to be found.

Text is a text string (in quotation marks), a number, or a reference to a cell containing one of those types, that is the string to be searched.

Position is a positive integer, or a reference to a cell containing a positive integer, that is the byte position from which the search starts. If Position is omitted, SEARCHB uses the value 1.


 * If Position is a non-integer value, then SEARCHB truncates it to an integer value.
 * If Position is less than 1, then SEARCHB reports an invalid argument error (Err:502).
 * After truncation, if Position is greater than the length of the string to be searched, then SEARCHB reports a #VALUE! error.
 * If no match is found, then SEARCHB reports a #VALUE! error. This is an error condition, which must be handled if used as an argument to another function.

Details specific to SEARCHB function
SEARCHB does not support wildcards or regular expressions.

Use the FINDB function if you need searches that are case-sensitive.

In (or LibreOffice > Preferences > LibreOffice Calc > Calculate on macOS), the setting for Search criteria = and <> must apply to whole cells has no effect on the behavior of SEARCHB.

Suggestions for handling the #VALUE! error that is returned when no match is found include:


 * returns "ERR: Missing Substring" and does not propagate the error from the SEARCHB function.
 * returns "ERR: Missing Substring" and does not propagate the error from the SEARCHB function.

Examples:
The following examples demonstrate the behavior of SEARCHB for strings comprising only single-byte characters.

The remaining examples demonstrate the behavior of SEARCHB for strings that involve double-byte characters. For ease of understanding, these examples avoid using text in languages such as Chinese, Japanese, and Korean, that utilize double-byte characters. Instead, as this is an English language page, these examples reference double-byte characters in the Halfwidth and Fullwidth Forms Unicode block that make sense in English. The Unicode character U+3000, known as the Ideographic Space, is also used in the first two of these examples.

Related LibreOffice functions:
FINDB

LEFTB

LENB

MIDB

REPLACEB

RIGHTB

SEARCH

ODF standard:
Section 6.7.8, part 2

Equivalent Excel functions:
SEARCHB