EXCEL ツール .NET Regex Testerで正規表現パターンをテストする Curtis Chau 更新日:6月 22, 2025 Download IronXL NuGet Download テキストの検索と置換 Start Free Trial Copy for LLMs Copy for LLMs Copy page as Markdown for LLMs Open in ChatGPT Ask ChatGPT about this page Open in Gemini Ask Gemini about this page Open in Grok Ask Grok about this page Open in Perplexity Ask Perplexity about this page Share Share on Facebook Share on X (Twitter) Share on LinkedIn Copy URL Email article In the ever-evolving landscape of software development, robust tools that facilitate efficient coding practices are indispensable. Among these, regular expressions (regex) are crucial in string manipulation and pattern matching. In the .NET framework, developers can harness the power of .NET Regex Tester to streamline the process of crafting and testing regex patterns. In this article, we embark on a journey to explore the functionalities and utilities offered by the .NET Regex Tester. Regex, a concise and powerful language for matching patterns in strings, is seamlessly integrated into the .NET framework. The .NET Regex Tester provides a dedicated environment for developers to fine-tune their regex patterns and test them against various input scenarios. This tool proves invaluable in debugging and refining regex expressions, ultimately leading to more efficient and error-resistant code. This article delves into the capabilities of .NET Regex Tester, providing insights and examples into its usage and integration with IronXL, which is a powerful library for working with Excel files in .NET applications. 1. Introduction to .NET Regex Tester .NET Regex Tester stands as a sophisticated web-based platform designed to streamline and elevate the intricacies of working with regular expressions within the .NET framework. This robust tool provides developers with an exceptionally user-friendly interface. It offers a seamless environment to input intricate regex patterns, rigorously test them against diverse sample strings, and intuitively visualize the corresponding matching results. Tailored specifically for the .NET flavor of regex, this tester guarantees flawless compatibility with the embedded regex engine in the .NET framework, thereby, ensuring precision and accuracy in pattern matching. What sets the .NET Regex Tester apart is its array of features, including real-time matching capabilities and comprehensive match information, collectively converging to catalyze a substantial enhancement in the overall regex development workflow. In essence, this tool emerges as an indispensable ally for developers navigating the intricate landscape of regex, fostering efficiency, accuracy, and ease in the development process. 2. Code Example - Using .NET Regex Tester To illustrate the practical application of the .NET Regex Tester, let's consider a scenario where we need to extract email addresses from a given text. Below is a sample C# code snippet demonstrating how to use the .NET Regex Tester to achieve this: using System; using System.Text.RegularExpressions; class Program { static void Main() { // Sample input text containing email addresses string inputText = "Sample text with email addresses: user1@example.com, user2@example.net"; // Regex pattern to match email addresses string pattern = @"\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b"; // Create a Regex object with the pattern Regex regex = new Regex(pattern); // Find matches of the pattern in the input text MatchCollection matches = regex.Matches(inputText); foreach (Match match in matches) { // Output each found email address Console.WriteLine($"Found email: {match.Value}"); } } } using System; using System.Text.RegularExpressions; class Program { static void Main() { // Sample input text containing email addresses string inputText = "Sample text with email addresses: user1@example.com, user2@example.net"; // Regex pattern to match email addresses string pattern = @"\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b"; // Create a Regex object with the pattern Regex regex = new Regex(pattern); // Find matches of the pattern in the input text MatchCollection matches = regex.Matches(inputText); foreach (Match match in matches) { // Output each found email address Console.WriteLine($"Found email: {match.Value}"); } } } Imports System Imports System.Text.RegularExpressions Friend Class Program Shared Sub Main() ' Sample input text containing email addresses Dim inputText As String = "Sample text with email addresses: user1@example.com, user2@example.net" ' Regex pattern to match email addresses Dim pattern As String = "\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b" ' Create a Regex object with the pattern Dim regex As New Regex(pattern) ' Find matches of the pattern in the input text Dim matches As MatchCollection = regex.Matches(inputText) For Each match As Match In matches ' Output each found email address Console.WriteLine($"Found email: {match.Value}") Next match End Sub End Class $vbLabelText $csharpLabel In this example, the regex pattern \b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b is used to match email addresses within the input text. The .NET Regex Tester allows developers to experiment with such patterns interactively, making the regex development process more intuitive. 2.1. Output Image 3. Introduction to IronXL IronXL is a powerful and versatile .NET library designed to streamline the handling of Excel files within your applications. Whether you're working on a desktop, web, or mobile application, IronXL provides a robust set of tools and features to simplify the process of reading, writing, and manipulating Excel files. Developed with the .NET framework in mind, IronXL seamlessly integrates into your C# or VB.NET projects, offering a straightforward and efficient solution for Excel-related tasks. Whether you're creating reports, importing data, or performing complex calculations, IronXL empowers developers with a comprehensive set of APIs and methods that make Excel file manipulation a breeze. 3.1. Install IronXL To effortlessly install IronXL, utilize the NuGet Package Manager within Visual Studio. The specific package to install is named IronXL.Excel. Paste the below command in the Package Manager Console and press enter. Install-Package IronXL.Excel 3.1. Code Example - Integrating IronXL with .NET Regex Tester To showcase the synergy between .NET Regex Tester and IronXL, consider a scenario where you want to extract data from an Excel file based on a specific pattern. The following C# code snippet demonstrates how to use IronXL in conjunction with .NET Regex Tester: using IronXL; using System; using System.Text.RegularExpressions; class Program { static void Main() { // Regex pattern to match email addresses string pattern = @"\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b"; // Load Excel file using IronXL WorkBook workbook = WorkBook.Load("datatable.xlsx"); WorkSheet workSheet = workbook.WorkSheets[0]; // Iterate through the specified range of cells and find matches foreach (var cell in workSheet["A2:A10"]) { string cellValue = cell.Text; // Use regex to find matches within the cell text MatchCollection matches = Regex.Matches(cellValue, pattern); foreach (Match match in matches) { // Output each found match with its cell address Console.WriteLine($"Found match in Excel at {cell.AddressString}: {match.Value}"); } } } } using IronXL; using System; using System.Text.RegularExpressions; class Program { static void Main() { // Regex pattern to match email addresses string pattern = @"\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b"; // Load Excel file using IronXL WorkBook workbook = WorkBook.Load("datatable.xlsx"); WorkSheet workSheet = workbook.WorkSheets[0]; // Iterate through the specified range of cells and find matches foreach (var cell in workSheet["A2:A10"]) { string cellValue = cell.Text; // Use regex to find matches within the cell text MatchCollection matches = Regex.Matches(cellValue, pattern); foreach (Match match in matches) { // Output each found match with its cell address Console.WriteLine($"Found match in Excel at {cell.AddressString}: {match.Value}"); } } } } Imports IronXL Imports System Imports System.Text.RegularExpressions Friend Class Program Shared Sub Main() ' Regex pattern to match email addresses Dim pattern As String = "\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b" ' Load Excel file using IronXL Dim workbook As WorkBook = WorkBook.Load("datatable.xlsx") Dim workSheet As WorkSheet = workbook.WorkSheets(0) ' Iterate through the specified range of cells and find matches For Each cell In workSheet("A2:A10") Dim cellValue As String = cell.Text ' Use regex to find matches within the cell text Dim matches As MatchCollection = Regex.Matches(cellValue, pattern) For Each match As Match In matches ' Output each found match with its cell address Console.WriteLine($"Found match in Excel at {cell.AddressString}: {match.Value}") Next match Next cell End Sub End Class $vbLabelText $csharpLabel This C# code utilizes the IronXL library to read data from an Excel file ("datatable.xlsx"). It defines a regular expression pattern for matching email addresses. The code then loads the Excel file, iterates through a specific range of cells (A2 to A10 in the first worksheet), extracts the text from each cell, and applies the defined regex pattern to find and print email addresses. For each match, the code outputs the cell address and the matched email value. The program is designed to demonstrate how to use IronXL to process Excel data and perform regular expression matching on cell values within a specified range. Input Image Output Image 4. Conclusion In conclusion, the .NET Regex Tester is an invaluable tool for developers working with regular expressions in the .NET framework. Its user-friendly interface and real-time matching capabilities enhance the efficiency of regex pattern development. Furthermore, when integrated with IronXL, developers can seamlessly extend their capabilities to work with Excel files, opening up new possibilities for data manipulation and analysis. By combining the strengths of these tools, developers can create robust applications with enhanced regex and Excel handling capabilities. IronXL offers a free trial license for all its users It is great for testing and development purposes. To get the detailed tutorial on IronXL to read the Excel file, visit here. Here is the download link of IronXL from the NuGet Package Manager website. Curtis Chau 今すぐエンジニアリングチームとチャット テクニカルライター Curtis Chauは、カールトン大学でコンピュータサイエンスの学士号を取得し、Node.js、TypeScript、JavaScript、およびReactに精通したフロントエンド開発を専門としています。直感的で美しいユーザーインターフェースを作成することに情熱を持ち、Curtisは現代のフレームワークを用いた開発や、構造の良い視覚的に魅力的なマニュアルの作成を楽しんでいます。開発以外にも、CurtisはIoT(Internet of Things)への強い関心を持ち、ハードウェアとソフトウェアの統合方法を模索しています。余暇には、ゲームをしたりDiscordボットを作成したりして、技術に対する愛情と創造性を組み合わせています。 関連する記事 更新日 9月 10, 2025 C#でPowerPointファイルを表示する方法 この記事では、MS PowerPoint Viewer をインストールせずに C# PowerPoint Viewer を作成します。 詳しく読む 更新日 6月 22, 2025 C#でテンプレートからPowerPointを作成する方法 この投稿では、C# を使用してテンプレートから PowerPoint を作成する方法を見ていきます 詳しく読む 更新日 6月 22, 2025 JavaでExcelファイルを読み取る方法(チュートリアル) Excelファイルの読み取りは時に複雑になることがあります。JavaでExcelファイルを読み取る方法は、Excelのセルが関与するため、JavaでWordファイルを読み取るのとは少し異なります。 詳しく読む C#でテンプレートからPowerPointを作成する方法JavaでExcelファイルを読み...
更新日 9月 10, 2025 C#でPowerPointファイルを表示する方法 この記事では、MS PowerPoint Viewer をインストールせずに C# PowerPoint Viewer を作成します。 詳しく読む
更新日 6月 22, 2025 JavaでExcelファイルを読み取る方法(チュートリアル) Excelファイルの読み取りは時に複雑になることがあります。JavaでExcelファイルを読み取る方法は、Excelのセルが関与するため、JavaでWordファイルを読み取るのとは少し異なります。 詳しく読む