View source code
Display the source code in std/regex.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
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.

Function std.regex.matchFirst

Find the first (leftmost) slice of the input that matches the pattern re. This function picks the most suitable regular expression engine depending on the pattern properties.

auto matchFirst(R, RegEx) (
  R input,
  RegEx re
)
if (isSomeString!R && isRegexFor!(RegEx, R));

auto matchFirst(R, String) (
  R input,
  String re
)
if (isSomeString!R && isSomeString!String);

auto matchFirst(R, String)()
if (isSomeString!R && isSomeString!String);

re parameter can be one of three types:

  • Plain string(s), 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.

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 std.regex by Walter Bright and Andrei Alexandrescu.

License

Boost License 1.0.