RegexToolbox 2.2.0
dotnet add package RegexToolbox --version 2.2.0
NuGet\Install-Package RegexToolbox -Version 2.2.0
<PackageReference Include="RegexToolbox" Version="2.2.0" />
paket add RegexToolbox --version 2.2.0
#r "nuget: RegexToolbox, 2.2.0"
// Install RegexToolbox as a Cake Addin #addin nuget:?package=RegexToolbox&version=2.2.0 // Install RegexToolbox as a Cake Tool #tool nuget:?package=RegexToolbox&version=2.2.0
RegexToolbox.NET
Regular expression tools for .NET developers.
RegexBuilder
RegexBuilder
is a class for building regular expressions in a more human-readable way using a fluent API. It offers a number of benefits over using raw regex syntax in strings:
- No knowledge of regular expression syntax is required: just use simple, intuitively-named classes and methods.
- Code is easier to read, understand and maintain.
- Code is safer and far less prone to regular expression syntax errors and programmer errors.
Here's an example:
var regex = new RegexBuilder()
.Text("Hello")
.Whitespace(RegexQuantifier.OneOrMore)
.Text("world!")
.BuildRegex();
But that's just a taste of what RegexBuilder
does: for full API documentation, head over to the project wiki.
Breaking changes in 2.0
All RegexBuilder
features that were deprecated in version 1.6 have been removed in 2.0.
Removed | Replaced with |
---|---|
StartGroup() ...EndGroup() |
Group() |
StartNamedGroup() ...EndGroup() |
NamedGroup() |
StartNonCapturingGroup() ...EndGroup() |
NonCapturingGroup() |
AddLogger() |
No replacement: logging has been removed. |
New in 1.6
Improved grouping methods
Version 1.6 introduces a simplified syntax for cleaner, less error-prone creating of groups. Go from this:
var regex = new RegexBuilder()
.StartGroup()
.Letter()
.Digit()
.BuildRegex(); // ERROR: forgot to call EndGroup()
to this:
var regex = new RegexBuilder()
.Group(r => r
.Letter()
.Digit()
) // Yay! Can't forget to end the group
.BuildRegex();
There are also new NamedGroup()
and NonCapturingGroup()
methods.
The old methods StartGroup()
, StartNamedGroup()
, StartNonCapturingGroup()
and EndGroup()
have been deprecated and will be removed in version 2.0.
More powerful AnyOf()
overloads
The AnyOf()
method is used to match any of a set of alternatives.
Previously it only let you specify strings as the alternatives, for example:
var animalLoverRegex = new RegexBuilder()
.Text("I love ")
.AnyOf("cats", "dogs", "tortoises")
.BuildRegex();
Now you can specify arbitrarily complex sub-regexes as the alternatives, such as:
// Match 3 letters followed by a full stop OR 4 digits followed by a comma
// (for some weird reason)
var regex = new RegexBuilder()
.AnyOf(
r => r
.Letter(Exactly(3))
.Text("."),
r => r
.Digit(Exactly(4))
.Text(",")
)
.BuildRegex();
New string
extension method
string.Replace(Regex regex, string replacement)
Logging deprecated (removed in version 2.0)
The logging feature introduced in version 1.3 wasn't proving as useful as I'd imagined and had introduced various maintenance difficulties. In this release the APIs are deprecated and do nothing. Logging will be removed altogether in version 2.0.
Also for .NET developers
MimeTypes.NET: MIME type constants for your .NET projects
RegexToolbox for other languages
RegexToolbox: Now you can be a hero without knowing regular expressions.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.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 |
---|---|---|
2.2.0 | 26,424 | 10/21/2023 |
2.1.0 | 9,780 | 12/18/2022 |
2.0.1-alpha4 | 151 | 12/18/2022 |
2.0.1-alpha3 | 236 | 9/18/2022 |
2.0.1-alpha2 | 221 | 9/18/2022 |
2.0.1-alpha1 | 200 | 1/3/2022 |
2.0.0 | 3,304 | 1/9/2021 |
2.0.0-alpha3 | 268 | 1/9/2021 |
2.0.0-alpha2 | 268 | 1/9/2021 |
2.0.0-alpha1 | 279 | 1/6/2021 |
2.0.0-alpha.9 | 173 | 1/9/2021 |
2.0.0-alpha.8 | 178 | 1/9/2021 |
1.6.0 | 383 | 1/5/2021 |
1.6.0-alpha3 | 297 | 1/2/2021 |
1.5.0 | 582 | 4/13/2020 |
1.5.0-alpha2 | 388 | 4/13/2020 |
1.5.0-alpha1 | 429 | 3/30/2020 |
1.4.1 | 624 | 2/8/2020 |
1.4.0 | 630 | 2/8/2020 |
1.3.0 | 588 | 11/6/2019 |
1.2.1 | 582 | 9/30/2019 |
1.2.0 | 560 | 9/17/2019 |
1.1.1 | 600 | 8/21/2019 |
1.1.0 | 569 | 8/18/2019 |
1.0.5 | 582 | 8/18/2019 |
1.0.4 | 570 | 8/17/2019 |
1.0.3 | 1,063 | 8/13/2017 |
1.0.2 | 948 | 8/8/2017 |
1.0.1 | 991 | 7/16/2017 |
1.0.0 | 1,333 | 7/15/2017 |