TEXTBEFORE Function (Gnumeric)
Get the part of a string before a delimiter, including last-occurrence and fallback examples.
Verification status: Official documentation referenced; example outcomes independently reasoned or arithmetically checked where stated. Not executed in Gnumeric. How formula examples are checked
TEXTBEFORE function in Gnumeric
Quick answer
TEXTBEFORE extracts everything before a specified delimiter occurrence. It is useful for removing a file extension, taking a username before @, or retaining the beginning of a structured product code.
=TEXTBEFORE("Red-Fish-Blue-Fish","-",2)
Expected result: Red-Fish: the second hyphen appears after the second word. With the occurrence argument omitted, the expected output is Red. Gnumeric’s source explicitly defines those meanings. Gnumeric source.
Exact Gnumeric syntax (1.12.61 and 1.12.62)
=TEXTBEFORE(text, delimiter, [instance_num], [match_mode], [match_end], [if_not_found])
| Argument | Required? | Meaning | Default |
|---|---|---|---|
text |
Yes | Text string/cell from which to extract. | None |
delimiter |
Yes | Literal delimiter string, or array of delimiter strings. | None |
instance_num |
No | Nonzero number identifying a delimiter occurrence; negatives count backward. | 1 |
match_mode |
No | 0 case-sensitive; 1 case-insensitive. |
0 |
match_end |
No | 0 normally; 1 allows the end of the text to act as a boundary. |
0 |
if_not_found |
No | Fallback result for unmatched delimiters/occurrences. | #N/A |
Use commas as shown for the English formula examples. If your locale displays a different list separator, confirm it in Gnumeric’s function assistant. instance_num=0 yields #VALUE! in the tagged implementation. The delimiter is literal text rather than a pattern. Source signature: SA|ffff. Source.
Step-by-step: usernames in an import sheet
- Enter the sample addresses in A2:A4 and headings
Email(A1) andUsername(B1). - Enter
=TEXTBEFORE(A2,"@",1,0,0,"INVALID")in B2. - Copy through B4.
- Compare with these expected results:
| A: Email text | Formula (relative to row) | Expected B result |
|---|---|---|
alex@example.ca |
=TEXTBEFORE(A2,"@",1,0,0,"INVALID") |
alex |
pat@shop.net |
=TEXTBEFORE(A3,"@",1,0,0,"INVALID") |
pat |
incomplete-address |
=TEXTBEFORE(A4,"@",1,0,0,"INVALID") |
INVALID |
The result represents the substring before the first @; it does not confirm the address is valid. Without the final fallback argument, the third row would be expected to return #N/A.
Advanced scenario: select a later or final delimiter
Input: Red-Fish-Blue-Fish.
| Formula | Expected result | Why |
|---|---|---|
=TEXTBEFORE("Red-Fish-Blue-Fish","-") |
Red |
First occurrence (instance_num=1). |
=TEXTBEFORE("Red-Fish-Blue-Fish","-",2) |
Red-Fish |
Second occurrence. |
=TEXTBEFORE("Red-Fish-Blue-Fish","-",-1) |
Red-Fish-Blue |
Last occurrence, counting backward. |
=TEXTBEFORE("Region-EAST/ON","east",1,1) |
Region- |
Case-insensitive matching. |
For filenames, =TEXTBEFORE("report.final.csv",".",-1) is expected to return report.final, cutting off only the final extension. This is different from the default first-period behaviour.
Errors, limitations and troubleshooting
#N/A: The requested delimiter occurrence does not exist. Compare uppercase/lowercase, leading spaces and whether the search string is exactly what you intended; useif_not_foundfor controlled fallback.#VALUE!: Zero is not a validinstance_numin Gnumeric’s implementation.- Wrong portion returned: Check whether you wanted the first (
1), second (2) or last (-1) delimiter. - Case behaviour: By default searches are case-sensitive; use
match_mode=1only when appropriate. match_end=1: In the tagged source, a positive out-of-range occurrence returns the whole original string, while a negative out-of-range occurrence returns an empty string. Do not silently assume other software handles these cases identically.- Delimiter arrays: The source supports them, but this guide does not claim tests of overlapping or multi-character arrays.
TEXTBEFOREdoes not itself enforce a filename or email-validation grammar. - Availability: Gnumeric 1.12.61 explicitly introduced this function. The Gnumeric 1.12.62 release tag confirms it still exists; installed plugin configuration may matter.
Compatibility and related Gnumeric tutorials
Excel for Microsoft 365/Excel 2024 also document TEXTBEFORE with similar parameter positions, but do not assume perfect interoperability without testing. Other spreadsheet programs may require combinations of search and extraction functions. Microsoft comparison.
Official reference and verification
Verification status: Official documentation checked; example outcomes were independently reasoned or arithmetically checked where applicable. Not executed in Gnumeric.
- No genuine Gnumeric screenshots are included; this guide does not use mock application images.