Workaround for LAMBDA Callback with REGEXREPLACE in Excel
Question details
The user wants to process regular expression matches individually by passing a LAMBDA callback function into Excel's REGEXREPLACE, similar to the MatchEvaluator delegate in .NET.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Performing advanced text manipulation where different regex matches require different custom transformations (e.g., doubling one match while tripling another).
- Observed behavior
- Excel's native REGEXREPLACE function does not currently accept a LAMBDA callback to evaluate and process matches individually.
Ensure you are using a Microsoft 365 subscription on the Beta Channel, as the new REGEXEXTRACT, REGEXMATCH, and REGEXREPLACE dynamic array functions are required to implement this workaround.
Use REGEXEXTRACT with REDUCE or MAP to process matches individually
Since REGEXREPLACE lacks native LAMBDA callback support, you can extract the matches into an array, process them with a LAMBDA function, and reconstruct the text.
This workaround involves breaking down the text using Excel's regex extraction tools, applying your custom logic to the resulting array, and putting the string back together.
Use the REGEXEXTRACT function on your target text to pull all regex matches into a dynamic array. Make sure to set the return_mode parameter to return all matches.
Wrap your extracted array inside a MAP or REDUCE function. Pass a custom LAMBDA function to evaluate each match individually, applying your specific logic (such as conditionally doubling or tripling specific numbers).
Once your array has been transformed by the LAMBDA function, use TEXTJOIN or a secondary REDUCE function combined with SUBSTITUTE to inject the modified matches back into the original string.

Submit a Feature Request via the Microsoft Feedback Portal
Since a native LAMBDA callback for REGEXREPLACE is not yet available, submitting a feature request helps Microsoft prioritize this functionality.
Experience Advanced Spreadsheet Processing with WPS Office
If you are looking for a powerful, cost-effective alternative to Microsoft Office for complex data handling and everyday spreadsheet tasks, WPS Office provides a comprehensive suite that easily meets your needs.
- 1. Download WPS Office: Visit the official WPS Office website and download the free installer for your operating system.
- 2. Install and Launch: Run the downloaded installer and follow the on-screen prompts to complete the setup. Once installed, launch WPS Spreadsheets.
- 3. Open your Excel workbook: Click on 'Open' and select your existing .xlsx files. WPS Spreadsheets will load them with complete formatting and formula compatibility.

Frequently Asked Questions
Does Excel's REGEXREPLACE support capture groups?
Yes, Excel's REGEXREPLACE function natively supports capturing groups. You can use standard regex syntax like $1, $2, etc., in your replacement string argument to reference specific parts of the matched text.
What is the purpose of the MAP function in this workaround?
The MAP function applies a custom LAMBDA formula to each element in the extracted match array. This allows you to perform conditional logic (like doubling or tripling a specific value) on individual matches before recombining them, replicating the behavior of a callback loop.
Why are the REGEX functions returning a #NAME? error in my spreadsheet?
The REGEXEXTRACT, REGEXMATCH, and REGEXREPLACE functions are currently available only to Microsoft 365 subscribers on the Beta Channel. If you are on an older version of Excel or the standard release channel, the software will not recognize these functions, resulting in a #NAME? error.




