Pinterest Pixel

How to Use Copilot for Regex Functions in Excel

John Michaloudis
Regular expressions (regex) use specific character patterns to search and manipulate text.
Writing these patterns can be difficult if you are not familiar with their syntax.

Copilot in Excel can help you create regex formulas using simple text prompts.

Let's see how to use Copilot for Regex functions in Excel.

Regular expressions (regex) use specific character patterns to search and manipulate text. Writing these patterns can be difficult if you are not familiar with their syntax. Copilot in Excel can help you create regex formulas using simple text prompts. Let’s see how to use Copilot for Regex functions in Excel.

Key Takeaways:

  • Regex patterns help you search and manipulate text in Excel.
  • Copilot can create Regex formulas using simple prompts.
  • REGEXTEST checks whether text matches a pattern.
  • REGEXEXTRACT extracts text based on a pattern.
  • REGEXREPLACE replaces text that matches a pattern.

 

What is Regex?

A regular expression (regex) is a sequence of characters that defines a search pattern.

You can use regex to find specific text, extract information, and replace matching characters. Excel provides REGEX functions to extract, validate, and replace text using these patterns.

 

Common Regex functions

REGEXTEST

REGEXTEST checks whether text matches a specified regex pattern. It returns TRUE or FALSE.

Syntax:

= REGEXTEST(text, pattern, [match_case])

  • text: The text string to be tested against the regular expression pattern.
  • pattern: The regular expression pattern to match against the text.
  • [match_case] (optional): A logical value indicating whether to consider case sensitivity (TRUE or FALSE).

regex function in excel

REGEXEXTRACT

REGEXEXTRACT finds and extracts text that matches a regex pattern.

Syntax:

= REGEXEXTRACT(text, pattern, [match_number], [occurrence], [match_case])

  • text: The text string from which to extract substrings.
  • pattern: The regular expression pattern used to match substrings.
  • [match_number] (optional): The index of the matching substring to extract (default is 1).
  • [occurrence] (optional): The occurrence of the matching substring to extract (default is all occurrences).
  • [match_case] (optional): A logical value indicating whether to consider case sensitivity (TRUE or FALSE).

regex function in excel

REGEXREPLACE

REGEXREPLACE replaces text matching a regex pattern with the text you specify.

Syntax:

= REGEXREPLACE(text, pattern, replacement, [match_case])

  • text: The text string in which to perform replacements.
  • pattern: The regular expression pattern used to match text to be replaced.
  • replacement: The text to replace the matched pattern.
  • [match_case] (optional): A logical value indicating whether to consider case sensitivity (TRUE or FALSE).

regex function in excel

 

How to Use Copilot for Regex Functions in Excel

REGEXTEST Formula

STEP 1: Open your Excel workbook and select the cell where you want to insert the formula.

Copilot for Regex Functions in Excel

STEP 2: Select the Copilot icon.

Copilot for Regex Functions in Excel

STEP 3: Enter a prompt describing what you want the formula to do. Include the cell reference and the pattern you want to check.

“Create a REGEXTEST formula to check whether the product code in cell A2 contains exactly three uppercase letters followed by four digits.”

Copilot for Regex Functions in Excel

STEP 4: Review the suggested formula. Ask Copilot to explain or modify the formula if required.

Copilot for Regex Functions in Excel

REGEXEXTRACT Formula

Use this prompt to extract an email address from the text string.

“Create a REGEXEXTRACT formula to extract the email address from the text in cell A2.”

Copilot for Regex Functions in Excel

REGEXREPLACE Formula

Use the prompt to remove unwanted characters from the list of phone numbers.

“Create a REGEXREPLACE formula to remove all non-numeric characters from the phone number in cell A2.”

Copilot for Regex Functions in Excel

Tips & Tricks

  • Specify the exact characters, numbers, or text you want to match in the prompt.
  • Make sure to mention which cell contains the source text.
  • Explain whether you want to extract, replace, or validate text.
  • If the Regex pattern is difficult to understand, ask Copilot to explain each symbol.
  • Test the formula with a few different values before using it on the entire dataset.

 

FAQs

1. What is Regex in Excel?

Regex uses text patterns to search, extract, and replace data.

2. How to use Copilot for regex functions in Excel?

Copilot can suggest Regex formulas based on your prompts.

3. What are the three Regex functions in Excel?

The three Regex functions in Excel are REGEXTEST, REGEXEXTRACT, and REGEXREPLACE.

4. Can REGEXEXTRACT extract email addresses?

The REGEXEXTRACT function can extract email addresses using a suitable Regex pattern.

5. Can Copilot explain Regex patterns?

You can ask Copilot to explain each symbol in a Regex pattern.

If you like this Excel tip, please share it


Founder & Chief Inspirational Officer

at

John Michaloudis is a former accountant and finance analyst at General Electric, a Microsoft MVP since 2020, an Amazon #1 bestselling author of 4 Microsoft Excel books and teacher of Microsoft Excel & Office over at his flagship MyExcelOnline Academy Online Course.

See also  Formula Completion with Copilot: How Copilot Predicts Formulas

Steps To Follow

Star 30 Days - Full Access Star

One Dollar Trial

$1 Trial for 30 days!

Access for $1

Cancel Anytime

One Dollar Trial
  • Get FULL ACCESS to all our Excel & Office courses, bonuses, and support for just USD $1 today! Enjoy 30 days of learning and expert help.
  • You can CANCEL ANYTIME — no strings attached! Even if it’s on day 29, you won’t be charged again.
  • You'll get to keep all our downloadable Excel E-Books, Workbooks, Templates, and Cheat Sheets - yours to enjoy FOREVER!
  • Practice Workbooks
  • Certificates of Completion
  • 5 Amazing Bonuses
Satisfaction Guaranteed
Accepted paymend methods
Secure checkout

Get Video Training

Advance your Microsoft Excel & Office Skills with the MyExcelOnline Academy!

Dramatically Reduce Repetition, Stress, and Overtime!
Exponentially Increase Your Chances of a Promotion, Pay Raise or New Job!

Learn in as little as 5 minutes a day or on your schedule.

Learn More!

Share to...