REGEX in Collabora Office: Extract and Replace Text with ICU Patterns
Use Collabora REGEX for extraction, capture-group replacements, selected occurrences, and global edits while handling documented no-match behavior correctly.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
Quick answer: =REGEX("Order AB-204; backup CD-17";"[A-Z]{2}-[0-9]+") has independently expected text AB-204. With Replacement omitted, REGEX extracts a match; adding Replacement changes the operation to replacement.
Syntax and optional argument positions
=REGEX(Text; Expression [; [Replacement] [; Flags|Occurrence]])
Text is the source text or a cell reference. Expression is an ICU regular expression. Replacement is optional text, including capture-group references. The fourth argument is either a supported flag or a numbered occurrence:
- “g”: replace all matches; the help explicitly describes global replacement, not global extraction.
- Occurrence: choose which match to extract or replace.
- Occurrence 0: return Text unchanged, according to the vendor.
When extracting a numbered occurrence, leave the Replacement slot empty: =REGEX(A2;pattern;;2). An empty replacement string "" is different from omitting that argument: it requests deletion of the selected match.
Example: extract identifiers from a message
Enter Order AB-204; backup CD-17 in A2. Use:
| Formula | Independent expected text |
|---|---|
=REGEX(A2;"[A-Z]{2}-[0-9]+") |
AB-204 |
=REGEX(A2;"[A-Z]{2}-[0-9]+";;2) |
CD-17 |
The pattern asks for two uppercase ASCII letters, a literal hyphen, and one or more ASCII digits. It does not accept lowercase identifiers or every Unicode letter/digit. Choose the character classes intentionally rather than assuming that a convenient pattern validates every possible identifier.
The examples were checked with independent text-pattern calculations for this simple subset. A separate regex engine is not a full substitute for ICU, so they do not certify every ICU feature or Unicode boundary.
Example: replace one match or all matches
For A2 above:
=REGEX(A2;"[A-Z]{2}-[0-9]+";"REDACTED")
has expected text Order REDACTED; backup CD-17. Adding ;"g" as the fourth argument gives Order REDACTED; backup REDACTED.
For the vendor’s own simple control, =REGEX("123456ABCDEF";"[:digit:]";"Z";"g") is documented to return ZZZZZZABCDEF. Removing the g flag replaces only the first digit, yielding Z23456ABCDEF.
A global flag must be deliberate. Inspect a few representative rows before applying a replacement to a large dataset, especially if the expression can match more text than intended.
Advanced example: rearrange captured pieces
=REGEX(A2;"([A-Z]{2})-([0-9]+)";"$1/$2";"g")
The independent expected text is Order AB/204; backup CD/17. Parentheses capture the letter and numeric portions, and $1 and $2 reuse them in the replacement.
The source’s explicit capture control is =REGEX("axbxcxd";"(.)x";"$1y";2), returning axbycxd. Only the second match is replaced; the first and third remain intact.
If you need a literal dot in a simple pattern, a character class such as [.] avoids treating the dot as the “any character” metacharacter. Do not assume plain punctuation is always literal inside a regular expression.
No match is different for extraction and replacement
The vendor explicitly states:
- Without Replacement, no match returns #N/A.
- With Replacement, no match returns the original Text unchanged.
Thus extracting [0-9]+ from No digits is documented to give #N/A, while replacing the same pattern in that text leaves No digits. An unchanged replacement result does not prove that the source was valid; it may mean the pattern matched nothing.
IFERROR can supply a fallback, but a broad fallback can also hide an invalid-pattern problem. Keep a diagnostic column when differentiating “missing identifier” from “broken formula” matters.
Advanced deletion and troubleshooting
The documented =REGEX("123456ABCDEF";"[126]";"";"g") deletes every 1, 2, or 6 and returns 345ABCDEF. For simpler fixed-text replacements, SUBSTITUTE may express the intended operation more directly.
Check straight quotation marks, pattern grouping, the empty third slot for extraction, and whether the fourth argument is a number or “g”. The source does not fully enumerate negative occurrence values, malformed-pattern errors, or unsupported flags, so this guide does not assign unverified native outcomes to those cases.
The vendor identifies namespace ORG.LIBREOFFICE.REGEX, outside OpenDocument 1.3 OpenFormula. This is not evidence of identical regex dialects or workbook support in other spreadsheet programs.
Availability and verification
The exact function is documented in Collabora Office 26.04 desktop help, retrieved and reviewed on October 17, 2026. This establishes a documentation scope, not the first release that introduced the function or the last version in which it works; those versions and any retirement date remain unestablished. Collabora Online and mobile support are not inferred from desktop help, nor is behavior in another spreadsheet product.
The examples are documentation-based expectations with independent calculations. They have not been executed in Collabora Office. No application screenshot or native error/coercion certification is implied. Formulas use English function names and semicolon argument separators.
References
- Collabora Office 26.04: REGEX (checked October 17, 2026).
- Editorial testing standards.