About This Article
This article was created through an automated generation flow utilizing generative AI. We verified the Microsoft Support REGEXEXTRACT / REGEXREPLACE specifications and organized them as tips for extracting and masking log strings using only Excel.Verification Status: 📘 Official Specifications Verified · Formula Sample Implemented · Target Excel Real Device Unverified
Extracting IDs, Emails, and IPs from Logs Using Only Excel — Using REGEXEXTRACT / REGEXREPLACE
With Microsoft 365 Excel, there are times when you no longer need to write VBA just to use regular expressions. Since you can extract with REGEXEXTRACT and replace with REGEXREPLACE, formatting logs for a single cell can be done with formulas alone.
For example, suppose you have the following string in A2.
REQ-20260906 user=tanaka@example.com ip=192.168.1.20
Extracting Only the Request ID
=REGEXEXTRACT(A2,"[A-Z]{2,10}-[0-9]{4,}")
The result is REQ-20260906.
Masking the Username Part of an Email Address
=REGEXREPLACE(A2,"([A-Za-z0-9._%+-]+)@([A-Za-z0-9.-]+.[A-Za-z]{2,})","***@$2")
You can replace tanaka@example.com like ***@example.com. This can also be applied as a simple masking method before passing logs to an AI.
Extracting Parts That Look Like IP Addresses
=REGEXEXTRACT(A2,"(?:[0-9]{1,3}.){3}[0-9]{1,3}")
This is a simple example to extract a “lookalike IPv4” format. Because 999.999.999.999 may also match, it should not be used as-is for strict IP address validation.
This Is Modern Excel
According to Microsoft’s specifications, REGEX-related functions use PCRE2-flavor regular expressions. This means they are more expressive than Excel’s native wildcards and allow you to bring regular expression knowledge directly into your formulas.
On the other hand, it is natural to choose the right tool for the job: Power Query for ETL processes involving tens of thousands of rows, or Office Scripts and VBA when processing multiple files.


コメント