RegexWrap 1.0.2
dotnet add package RegexWrap --version 1.0.2
NuGet\Install-Package RegexWrap -Version 1.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="RegexWrap" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RegexWrap" Version="1.0.2" />
<PackageReference Include="RegexWrap" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add RegexWrap --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: RegexWrap, 1.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package RegexWrap@1.0.2
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=RegexWrap&version=1.0.2
#tool nuget:?package=RegexWrap&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
RegexWrap
Uma API fluente para construir expressões regulares de forma legível e encadeada.
RegexWrap é uma biblioteca .NET que permite criar expressões regulares de forma fluente, encadeada e muito mais legível. Ideal para quem quer evitar a complexidade e a verbosidade das regex tradicionais.
✨ Instalação
Instale via NuGet:
dotnet add package RegexWrap --version 1.0.0-preview
🚀 Exemplo Rápido
using RegexWrap;
var regex = RegexBuilder.StartPattern()
.StartOfLine()
.JustLetters().OneOrMore()
.WhiteSpace()
.JustNumbers().Repeat(2, 4)
.EndOfLine()
.ReturnAsRegex();
bool isMatch = regex.IsMatch("Nome 1234"); // true
🔤 Caracteres
| Método | Descrição |
|---|---|
JustNumbers() |
Dígitos (\d) |
JustLetters() |
Letras ([a-zA-Z]) |
WhiteSpace() |
Espaços em branco (\s) |
AnyChar() |
Qualquer caractere (.) |
Lit(string) |
Literal escapado |
🔁 Repetições
| Método | Descrição |
|---|---|
Repeat(n) |
Repete exatamente n vezes ({n}) |
Repeat(min, max) |
Repete entre min e max vezes ({min,max}) |
Optional() |
Opcional (?) |
OneOrMore() |
Um ou mais (+) |
ZeroOrMore() |
Zero ou mais (*) |
🧩 Agrupamentos
| Método | Descrição |
|---|---|
Group(Action<RegexWrap>) |
Grupo capturador ((...)) |
NonCapturingGroup(Action<>) |
Grupo não capturador ((?:...)) |
Or() |
Alternância entre padrões (|) |
📍 Âncoras
| Método | Descrição |
|---|---|
StartOfLine() |
Início da linha (^) |
EndOfLine() |
Fim da linha ($) |
🧪 Exemplos Avançados
Validar um e-mail simples
var emailRegex = RegexBuilder.StartPattern()
.StartOfLine()
.Group(r => r.JustLetters().OneOrMore())
.Lit("@")
.Group(r => r.JustLetters().OneOrMore())
.Lit(".")
.Group(r => r.JustLetters().Repeat(2, 3))
.EndOfLine()
.ReturnAsRegex();
bool isValid = emailRegex.IsMatch("teste@email.com"); // true
Número de telefone (formato: (XX) XXXX-XXXX)
var phoneRegex = RegexBuilder.StartPattern()
.Lit("(").JustNumbers().Repeat(2).Lit(")")
.WhiteSpace()
.JustNumbers().Repeat(4)
.Lit("-")
.JustNumbers().Repeat(4)
.ReturnAsRegex();
bool isValid = phoneRegex.IsMatch("(41) 9999-1234"); // true
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.2 | 246 | 8/28/2025 |
| 1.0.1-preview | 228 | 8/28/2025 |
| 1.0.0-preview | 238 | 8/28/2025 |