searchb

Returns the starting position in bytes of the first instance of needle in haystack. Returns null if needle is not in haystack. Counting starts from 1 (not 0).

Always counts in the natural direction of the advertiser’s locale.

Intended mainly for languages that do not use a Latin character set, such as Japanese and Chinese. If the string or inventory attribute is in a language that uses a Latin, single-byte character set, such as English, searchb returns the same value as search

Syntax

searchb(needle, haystack)
Learn more about syntax for functions.

Parameter

needle and haystack can be any of the following:

Case insensitive

Text searches are case insensitive.

Empty character

If you include an expression or formula column in this function, the expression or formula column could evaluate to an empty string.

Be aware that searching for an empty string always returns 1. That is, searchb("", "GDN") evaluates to 1.

Examples

  • searchb("Δ", "ΓaΔbΘc") returns 4, which is the starting byte of the 3rd character. (The first character of haystack is 2 bytes, and the second character is 1 byte.)

  • searchb("a", "ΓaΔbΘc") returns 3, which is the starting byte of the 2nd character.

  • searchb("ー", "スニーカー") returns 5, which is the location of the first when counting bytes in a double-byte character set.

  • searchb("", "ΓaΔbΘc") returns 1 because the function is searching for an empty string. Note that searching for an empty string returns 1, even though first character is 2 bytes

Was this helpful?
How can we improve it?