SEARCHB Function (LibreOffice Calc)
Locate text by byte-counted position with LibreOffice SEARCHB. Compare case-insensitive matches, optional starts, mixed-width text and document-dependent pattern handling.
Verification status: Eight ordinary formula examples were recalculated in LibreOfficeDev 26.8.0.0.alpha0 (2c87e51eeaa2b413ff4ae097b2705eea1995d8e5) using headless XLSX import and forced recalculation. Exact saved text/positions and both controls were checked. LibreOffice 26.8.1.1 was source-checked only; no stable-release or GUI execution is claimed. How formula examples are checked
Quick answer: =SEARCHB("国";"中国") returned 3 in the tested development build.
Availability and version history
- Introduced: Introduced in LibreOffice 6.0.
- Supported in: LibreOffice 26.8 Help and 26.8.1.1 registration; no retirement is established.
- Scope: Desktop Calc, English semicolon-separated formulas. The byte convention is not a file-encoding byte offset.
- Checked: October 14, 2026. Eight listed formulas were recalculated in LibreOfficeDev 26.8.0.0.alpha0 using headless XLSX import. Stable releases and 26.8.1.1 were not executed.
What SEARCHB returns
SEARCHB returns a one-based byte-counted position without requiring matching letter case. In the ordinary examples here, ASCII characters count as one unit and the selected Chinese and full-width characters count as two. The matching rules and the returned position’s units are separate parts of the function. Function Help.
Syntax and arguments
SEARCHB(FindText; Text[; Position])
Square brackets mark an optional argument; do not type them. FindText is the text or search expression to locate. Text is the string searched. Position is an optional one-based byte start and defaults to 1. The callback accepts two or three arguments and uses the document’s search-type detection; the table intentionally uses literal search terms without pattern metacharacters.
Eight reproducible examples
The native column is from LibreOfficeDev 26.8.0.0.alpha0, build 2c87e51eeaa2b413ff4ae097b2705eea1995d8e5, using headless XLSX import and forced recalculation. Text is quoted to distinguish empty strings and spaces. Delimiting quotation marks are not returned characters.
| Formula | Independent reference | LibreOfficeDev result |
|---|---|---|
=SEARCHB("国";"中国") |
3 |
3 |
=SEARCHB("b";"A中国B") |
6 |
6 |
=SEARCHB("中";"A中国B") |
2 |
2 |
=SEARCHB("a";"aAa";2) |
2 |
2 |
=SEARCHB("a";"LibreOffice Calc") |
15 |
15 |
=SEARCHB("中";"中国中国";3) |
5 |
5 |
=SEARCHB("国";"中国";2) |
3 |
3 |
=SEARCHB("FFI";"office") |
2 |
2 |
Practical worksheet
In A中国B, lowercase b finds uppercase B at byte position 6. A character-counting SEARCH would describe a different positional unit. Use a returned SEARCHB index with other byte-aware text functions when that is the intended field convention.
Starting at position 2 in aAa, SEARCHB(“a”;“aAa”;2) finds uppercase A immediately and returns 2. FINDB’s case-sensitive version skips it and returns 3. This is a useful controlled example because the strings and start position are identical.
For an imported identifier field, decide whether letter case is meaningful before choosing the function. A case-insensitive match may be suitable for a label, but it can conceal a meaningful difference in a case-sensitive code.
Advanced interpretation and checks
The implementation first creates a suffix beginning at the requested byte position. It passes that suffix and the search expression to LibreOffice’s text-search machinery, then converts the matched prefix’s length back into the byte-counting convention and adds Position.
Because the suffix is built with the same helper as RIGHTB, a start within a two-unit character can introduce a space for the incomplete fragment. In the listed example that starts at position 2 of 中国, searching for 国 still produces position 3. The byte start and the visible-character start are not interchangeable.
Search-type detection reads the document settings. Depending on the applicable settings and expression, pattern behavior can differ from a literal FINDB search. This review did not run wildcard or regular-expression cases, so the ordinary table should not be treated as a universal pattern-syntax test.
The matching stage is case-insensitive, but it is not a promise that every Unicode distinction is ignored. The examples cover ASCII case changes and literal CJK/full-width characters; they do not establish locale-independent equivalence for all scripts. Inspected implementation.
Boundaries and troubleshooting
A supplied Position below 1 follows an illegal-argument branch. A start whose zero-based offset is at or beyond the text’s byte length, or an unsuccessful search, follows a no-value branch. These are inspected source conditions, not executed invalid-input examples here.
Unlike FINDB, the SEARCHB guard does not first subtract the search term’s byte length when checking the starting range. Similar-looking formulas can therefore reach different validation branches before attempting the search.
The helper has a configured-Japanese-language special case for backslash and euro sign. Those locale-sensitive characters were excluded from the fixture. As with MIDB, the returned units are not UTF-8 file offsets and should not be used to cut an encoded file directly.
Related functions
Official evidence and checking scope
- Function-specific Help
- Complete versioned callback
- English native-name registration
- Byte classification and left/right helpers
The exact saved formulas and text were reconciled, including ODF repeated-space elements. The stale SUM cache refreshed to 3 and the uncached SUM returned 7. This is headless development-build evidence, not a stable-release or GUI test.