[PR #699] [MERGED] GUID Pattern support in RegexMatcher #1041

Closed
opened 2025-12-29 08:34:26 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/wiremock/WireMock.Net/pull/699
Author: @brogdogg
Created: 12/8/2021
Status: Merged
Merged: 12/11/2021
Merged by: @StefH

Base: masterHead: feature/685


📝 Commits (4)

  • 469e525 Add the RegexGuid class
  • f1811f9 Use of RegexGuid in the RegexMatcher
  • ac9404f Fix up the CodeFactor violations
  • 93ed8f4 Rename RegexGuid --> RegexExtended

📊 Changes

3 files changed (+175 additions, -2 deletions)

View changed files

📝 src/WireMock.Net/Matchers/RegexMatcher.cs (+3 -2)
src/WireMock.Net/RegularExpressions/RegexExtended.cs (+72 -0)
test/WireMock.Net.Tests/RegularExpressions/RegexExtendedTests.cs (+100 -0)

📄 Description

Adding a new RegexGuid class, extending the System.Text.RegularExpressions.Regex class, to support patterns for identifying a GUID with respect to the way the System.Guid.ToString() formats a new GUID.

Additionally, the RegexMatcher was updated to use this new RegexGuid class.

Potential use:

// Create a regex matcher with a \GUIDD pattern (i.e. only match on all caps GUID with format D
var matcher = new RegexMatcher("\GUIDD");
// Would not match, since there are lower case
double result = matcher.IsMatch("5ae7dbb5-ea2c-4c55-ac38-9634681f168d");
// Would match, as it is a valid GUID in all upper case and valid with respect o the
// format D specifer.
result = matcher.IsMatch("5AE7DBB5-EA2C-4C55-AC38-9634681F168D");

This is a suggested change to address feedback to #685


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/wiremock/WireMock.Net/pull/699 **Author:** [@brogdogg](https://github.com/brogdogg) **Created:** 12/8/2021 **Status:** ✅ Merged **Merged:** 12/11/2021 **Merged by:** [@StefH](https://github.com/StefH) **Base:** `master` ← **Head:** `feature/685` --- ### 📝 Commits (4) - [`469e525`](https://github.com/wiremock/WireMock.Net/commit/469e5258e831b0e80f88ce7a2f9cb10b65c8be31) Add the RegexGuid class - [`f1811f9`](https://github.com/wiremock/WireMock.Net/commit/f1811f955478eebdb2bceecb494927129007e14f) Use of RegexGuid in the RegexMatcher - [`ac9404f`](https://github.com/wiremock/WireMock.Net/commit/ac9404f8962aa37bbf78efda0a2ed4e8071b253e) Fix up the CodeFactor violations - [`93ed8f4`](https://github.com/wiremock/WireMock.Net/commit/93ed8f4ea48907c227c72825bed22077f387101e) Rename RegexGuid --> RegexExtended ### 📊 Changes **3 files changed** (+175 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/WireMock.Net/Matchers/RegexMatcher.cs` (+3 -2) ➕ `src/WireMock.Net/RegularExpressions/RegexExtended.cs` (+72 -0) ➕ `test/WireMock.Net.Tests/RegularExpressions/RegexExtendedTests.cs` (+100 -0) </details> ### 📄 Description Adding a new `RegexGuid` class, extending the `System.Text.RegularExpressions.Regex` class, to support patterns for identifying a GUID with respect to the way the [System.Guid.ToString()](https://docs.microsoft.com/en-us/dotnet/api/system.guid.tostring?view=net-6.0) formats a new GUID. Additionally, the `RegexMatcher` was updated to use this new `RegexGuid` class. Potential use: ```c# // Create a regex matcher with a \GUIDD pattern (i.e. only match on all caps GUID with format D var matcher = new RegexMatcher("\GUIDD"); // Would not match, since there are lower case double result = matcher.IsMatch("5ae7dbb5-ea2c-4c55-ac38-9634681f168d"); // Would match, as it is a valid GUID in all upper case and valid with respect o the // format D specifer. result = matcher.IsMatch("5AE7DBB5-EA2C-4C55-AC38-9634681F168D"); ``` This is a suggested change to address feedback to #685 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 08:34:26 +01:00
adam closed this issue 2025-12-29 08:34:27 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net#1041