REGEXTEST Function in Gnumeric: Syntax, Examples and Troubleshooting
Check whether text contains a regular-expression match. Learn exact arguments, reproducible examples and common errors.
Verification status: Official documentation referenced; example outcomes independently reasoned or arithmetically checked where stated. Not executed in Gnumeric. How formula examples are checked
Quick answer: REGEXTEST returns TRUE when a regular-expression pattern occurs anywhere in supplied text, otherwise FALSE. Use anchors if you want the entire cell to match rather than a fragment. For example =REGEXTEST("ID-123","^ID-[0-9]{3}$") has the expected result TRUE.
Syntax and arguments
=REGEXTEST(text, pattern, [case_insensitive])
| Argument | Required? | Type and role |
|---|---|---|
text |
Yes | A string or reference to a text cell to search. |
pattern |
Yes | A regex string. [0-9]{3} means exactly three ASCII digits. |
case_insensitive |
No | Boolean; FALSE by default (case-sensitive); pass TRUE to ignore letter case. |
The TRUE setting changes matching case, not the underlying string. The source compiles the regex with a case-insensitive flag only when this argument is true; invalid regex syntax returns a #VALUE!-type formula error. This is a search, not a data validator unless you use ^...$.
Reproducible worksheet example: validate product codes
- In A1 type
Input code; in B1 typeStrict match; in C1 typeIgnore case. - Enter the following literal values in A2:A6.
- In B2 enter
=REGEXTEST(A2,"^ID-[0-9]{3}$"); fill B2:B6. - In C2 enter
=REGEXTEST(A2,"^id-[0-9]{3}$",TRUE); fill C2:C6. - Check each expected Boolean below; these are independently calculated, not observed application results.
| Row | A: Input code | B: exact uppercase | C: case-insensitive |
|---|---|---|---|
| 2 | ID-123 |
TRUE |
TRUE |
| 3 | id-007 |
FALSE |
TRUE |
| 4 | No code |
FALSE |
FALSE |
| 5 | ORD-42 |
FALSE |
FALSE |
| 6 | ID-xyz |
FALSE |
FALSE |
Why: The strict pattern requires uppercase ID, a hyphen, and exactly three digits with nothing before or after. In C, TRUE allows lowercase id, so row 3 passes.
Advanced application: distinguish a match anywhere from a valid complete field
For A2=Order ID-123 archived:
=REGEXTEST(A2,"ID-[0-9]{3}")
Expected: TRUE, because the text contains ID-123. The anchored form =REGEXTEST(A2,"^ID-[0-9]{3}$") is expected to be FALSE because extra words occur around the code. Use full-cell validation for importing fixed-format identifiers; use unanchored search to find an embedded code in notes.
To make the expression reusable, put the pattern ^ID-[0-9]{3}$ as literal text in D1 and enter =REGEXTEST(A2,$D$1). The result for A2=ID-123 is TRUE; $D$1 keeps the pattern reference fixed as you fill down.
Troubleshooting and edge cases
- Everything matches unexpectedly: A pattern such as
IDfinds a substring. Add^and$to require the whole cell to match. - Case differences: With omitted third argument,
id-123does not match^ID-[0-9]{3}$. UseTRUEwhen desired, and review for unintended matches. - Literal punctuation:
.means any character in most regex syntax. To match a literal period safely without a backslash, use[.]. - Invalid pattern (
[0-9): The inspected Gnumeric source returns a#VALUE!-type error for a regex compile failure. The exact translated/error display has not been native-tested. - Nontext identifiers or leading zeros: Keep codes stored as text; converting
007to numeric7destroys the original string shape. - Import/application mismatch: Regex engines differ; validate complex lookarounds, Unicode character classes and locale-specific rules in the target release rather than assuming an Excel/Google Sheets pattern transfers unchanged.
Compatibility and related guides
Excel for Microsoft 365 documents a REGEXTEST function using case_sensitivity, where 1 means case-insensitive; its documented engine is PCRE2. Gnumeric’s third argument is a Boolean named case_insensitive. This tutorial does not certify identical behavior for all advanced regex features or Excel versions. Other tools may use REGEXMATCH or different names/engines.
Availability and formula conventions
These examples target Gnumeric 1.12.62, whose official release announcement lists this function as newly introduced. Its registered name and argument information were checked against the GNOME source-code function definitions and string-function registry (GitHub’s GNOME mirror, pinned to commit 5d556a736fa3). The project’s release-specific source archive was enumerated in the pre-existing independent catalogue audit, but its bytes were not downloaded again in this batch. The public Gnumeric function index lags the audited release registry; absence from that list does not prove absence from 1.12.62. This guide does not promise availability in earlier versions or every downstream installation with different plugins.
Formulas use an English-language, comma-separated argument style with decimal dots where necessary. Regional settings can change the displayed argument separator and translated user interface; if pasting fails, insert the function through Gnumeric’s own function editor. Regex patterns are strings, so put double quotes around literal patterns in a formula; cell references such as A2 do not take quotes. A regex searches for a match within a string unless you explicitly anchor it with ^ and $. The implementation calls GLib GRegex; pattern portability with other spreadsheet regex engines is not guaranteed.
Official reference and verification
- Gnumeric — function documentation
- GNOME source-code function definitions
- string-function registry
- Gnumeric function index
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.