Returns the starting position in bytes of the first instance of needle
in haystack
. Returns null if needle
is not in the haystack
. Counting starts from one (1) (not zero ()).
Always counts in the natural direction of the selected locale.
Intended mainly for languages that do not use a Latin character set, such as Japanese and Chinese. If the string or feed attribute is in a language that uses a Latin, single-byte character set such as English, search_byte
returns the same value as search.
Syntax
search_byte("needle", "haystack")
Parameter
needle
and haystack
can be any of the following:
- Static text, such as "GDN".
- An expression or formula column that returns a text value.
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.
Searching for an empty string always returns 1. That is, searchb("", "GDN")
evaluates to 1.
Examples
-
search_byte("Δ", "Γ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.) -
search_byte("a", "ΓaΔbΘc")
returns 3, which is the starting byte of the 2nd character. -
search_byte("ー", "スニーカー")
returns 5, which is the location of the first ー when counting bytes in a double-byte character set. -
search_byte("", "Γ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