Contact

REGEXEXTRACT in ONLYOFFICE: Extract Matches and Capture Groups

Text and Data Intermediate ONLYOFFICE Spreadsheet Editor

Extract first matches, all matches or capture groups in ONLYOFFICE, with tested two-cell array entry, text results and optional-group errors.

Verification status: Two scalar cases and three explicit two-cell horizontal Ctrl+Shift+Enter array cases were checked in ONLYOFFICE Desktop Editors Community 10.0.0.169 on Linux. Automatic dynamic spilling was not tested; other examples retain their stated evidence scope. How formula examples are checked

Quick answer: =REGEXEXTRACT("A12B34","[0-9]+") returns the text 12. Use return mode 1 for all matches, or mode 2 for the capturing groups from the first match. The multiple-result examples below use an explicitly selected array output range in the tested desktop build.

Availability and version history

  • Introduced: Official Desktop Editors and Docs histories add REGEXEXTRACT in 9.3.0 on February 25, 2026.
  • Availability: Currently catalogued; the examples marked native were tested in Desktop Editors Community 10.0.0.169 on Linux. No final support endpoint is established.
  • Scope: The individual help destination was unavailable. Syntax is backed by the linked official implementation; native results apply to the named desktop build, not automatically to web or mobile clients.
  • Checked: October 14, 2026, using official sources, independent pattern checks and scalar plus explicit two-cell array tests.

Syntax and return modes

=REGEXEXTRACT(text, pattern, [return_mode], [case_sensitivity])

The pinned official function-specific implementation defines two required text arguments and two optional numeric arguments:

Argument Meaning
text Text to search, or a reference to a text cell
pattern Regular expression written as text, without surrounding / / delimiters
return_mode 0: first complete match; 1: all complete matches; 2: capturing groups from the first match. Default 0
case_sensitivity 0: case-sensitive; 1: case-insensitive. Default 0

Use the listed integer modes. Mode 2 is not a request for the second match. Parentheses in the pattern create the groups returned by that mode.

The returned matches are text, even when they contain only digits. That is useful for identifiers with leading zeros. Convert a result with VALUE only when it should become a quantity; converting the text 007 to a number intentionally loses its leading zeros.

First-match worksheet

In a blank worksheet, use A1:C1 for Text, Pattern, and First match. Enter A2:B5 without enclosing quote characters:

Row A: Text B: Pattern Expected C
2 A12B34 [0-9]+ text 12
3 Item XY-007 ready [A-Z]{2}-[0-9]{3} text XY-007
4 ref: 007 / 042 [0-9]+ text 007
5 ABC [0-9]+ #N/A

Put =REGEXEXTRACT(A2,B2) in C2 and fill through C5. The literal equivalents of rows 2 and 5 were tested natively: the first returned a text value, and the missing match returned #N/A. Rows 3 and 4 are independently checked pattern examples.

The + after the digit class collects a whole run. Without it, [0-9] would select one digit. The function searches inside the text unless the pattern itself constrains the beginning or ending.

To show an explicit missing-match label, put =IFERROR(C5,"No match or formula error") in D5. IFERROR catches errors broadly, so this label does not pretend to distinguish an absent match from a malformed pattern. Keep C5 available for diagnosis.

Return both matches with an array formula

On a separate blank worksheet, select B9:C9. In the formula bar enter:

=REGEXEXTRACT("A12B34","[0-9]+",1)

Press Ctrl+Shift+Enter. In Desktop Editors Community 10.0.0.169, B9 contained text 12 and C9 contained text 34. When the same formula had been imported as an ordinary single-cell formula, only the first value was returned.

This agrees with ONLYOFFICE’s array-formula instructions: select the output range before committing an array formula. The editor adds the array braces; do not type them yourself. Select the whole array when changing or deleting it.

The test establishes this explicit two-cell horizontal result. It does not establish automatic dynamic spilling, how an undersized range should be handled in every version, or every interaction between array inputs and multiple matches. Size the selected range for the result you intend to inspect.

Capture the parts of a code

On another blank worksheet, select B9:C9 and enter the following with Ctrl+Shift+Enter:

=REGEXEXTRACT("AB-204","([A-Z]+)-([0-9]+)",2)

The native results were AB in B9 and text 204 in C9. The hyphen is part of the overall match but is outside both capturing groups, so neither returned field includes it.

This is a useful way to separate a department prefix from a reference number. Keep the number as text if fixed width matters. A more restrictive production pattern could use {2} and {3} instead of + when those widths are required; validate that rule against the actual code specification.

For a practical reference-based version, enter AB-204 in A2, select B2:C2, and array-enter =REGEXEXTRACT(A2,"([A-Z]+)-([0-9]+)",2). The independent expected fields are again AB and 204. This additional worksheet form was not a separate native test.

Optional captures can be errors

An unmatched optional group did not become a blank in the native test. Array-entering the following into B9:C9 returned A followed by #N/A:

=REGEXEXTRACT("A","(A)(B)?",2)

The whole pattern matches, but the second group is absent. Do not treat that second-cell error as proof that the complete input failed to match. The inspected implementation also maps empty capturing-group strings to a not-available error; the native case above specifically tests an unmatched optional group.

Use REGEXTEST when the only question is whether a pattern matches. Use REGEXREPLACE when the goal is to rewrite matching text.

Troubleshooting and compatibility

  • Only one value appears: inspect whether the formula was entered as an ordinary cell formula or as an array over the intended output range.
  • Digits behave like text: that is the extraction result type, not a failed calculation.
  • Case differs: pass 1 as the fourth argument, with an explicit return mode, when case-insensitive matching is intended.
  • Pattern rejected: check balanced brackets and parentheses. The implementation uses JavaScript regular expressions with additional product handling; do not assume complete PCRE compatibility.
  • Imported workbook differs: recheck formula entry, output range and exact application build. The native tests here do not certify every regex engine feature or export round trip.