SEARCHB
The SEARCHB function returns the position of the searched text within the viewed text.
Counts double-byte characters, such as hieroglyphs, as 2 characters.
The function is case insensitive, supports wildcards “?” and “*”.
This feature can be useful for working with texts containing characters from different languages and character sets, including double-byte characters such as Chinese, Japanese, and Korean.
Syntax
SEARCHB(find_text, within_text, [start_num])
| Argument | Description | Permitted values |
|---|---|---|
| find_text | String to be found in the “within_text” argument | Text string or reference to a cell containing text |
| within_text | Text in which you need to find the first occurrence of the value specified by the “find_text” argument | Text string or reference to a cell containing text |
| [start_num] | (optional) Character in the “within_text” argument from which the search should start | Integer ≥1 or a reference to a cell containing a number |
Examples of use
Search for a two-byte character
If cell A1 contains the text “こんにちは” (hello in Japanese) and you want to find the position of the character “に”:
=SEARCHB("に", A1)
The function will return 3, since “に” is in the third position.
Search with initial position specified
If you want to start searching from the third character:
=SEARCHB("に", A1, 3)
The function will also return 3, since the character “に” is in the same position.
"find_text" argument is not found in the "within_text" argument
If you are searching for text that is not contained in the string, for example:
=SEARCHB("猫", A1)
The function will return the #VALUE! error, since "猫" symbol is not found in the string.
Notes
- The SEARCHB function takes into account the byte length of characters, which makes it useful for working with texts in languages that use double-byte characters.
- If the value of the start_num argument exceeds the length of the within_text argument, the function will return the #VALUE! error.