View source code
Display the source code in std/regex.d from which this page was generated on
github.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Page wiki
View or edit the community-maintained wiki page associated with this page.
Function std.regex.matchFirst
Find the first (leftmost) slice of the that
matches the pattern input. This function picks the most suitable
regular expression engine depending on the pattern properties.
re
parameter can be one of three types:
re
- Plain string, in which case it's compiled to bytecode before matching.
Regex!char (wchar/dchar) that contains a pattern in the form of compiled bytecode.StaticRegex!char (wchar/dchar) that contains a pattern in the form of compiled native machine code.
Prototypes
auto matchFirst(R, RegEx)( R input, RegEx re ) if (isSomeString!R && is(RegEx == Regex!(BasicElementOf!R))); auto matchFirst(R, String)( R input, String re ) if (isSomeString!R && isSomeString!String);
Returns
Captures containing the extent of a match together with all submatches
if there was a match, otherwise an empty Captures object.
Authors
Dmitry Olshansky,
API and utility constructs are modeled after the original
by Walter Bright and Andrei Alexandrescu.
std.regex