
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Regular expression tools for .NET developers.
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:
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.
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. |
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.
AnyOf()
overloadsThe 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();
string
extension methodstring.Replace(Regex regex, string replacement)
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.
MimeTypes.NET: MIME type constants for your .NET projects
FAQs
Regular expression tools for .NET developers
We found that regextoolbox demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.