Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
regex
A Rust library for parsing, compiling, and executing regular expressions. This particular implementation of regular expressions guarantees execution in linear time with respect to the size of the regular expression and search text. Much of the syntax and implementation is inspired by RE2.
Documentation
Module documentation with examples. The module documentation also include a comprehensive description of the syntax supported.
Documentation with examples for the various matching functions and iterators
can be found on the
Regex
type.
Usage
Add this to your Cargo.toml
:
[]
= "0.1"
and this to your crate root:
extern crate regex;
Here's a simple example that matches a date in YYYY-MM-DD format and prints the year, month and day:
extern crate regex;
use Regex;
If you have lots of dates in text that you'd like to iterate over, then it's easy to adapt the above example with an iterator:
extern crate regex;
use Regex;
const TO_SEARCH: &'static str = "
On 2010-03-14, foo happened. On 2014-10-14, bar happened.
";
This example outputs:
year: 2010, month: 03, day: 14
year: 2014, month: 10, day: 14
Usage: regex!
compiler plugin
The regex!
compiler plugin will compile your regexes at compile time. This
only works with a nightly compiler.
The
documentation explains the trade
offs.
Here is a small example:
extern crate regex;
Notice that we never unwrap
the result of regex!
. This is because your
program won't compile if the regex doesn't compile. (Try regex!("(")
.)
Usage: a regular expression parser
This repository contains a crate that provides a well tested regular expression parser and abstract syntax. It provides no facilities for compilation or execution. This may be useful if you're implementing your own regex engine or otherwise need to do analysis on the syntax of a regular expression. It is otherwise not recommended for general use.
Documentation for regex-syntax
with
examples.
License
regex
is primarily distributed under the terms of both the MIT license and
the Apache License (Version 2.0), with portions covered by various BSD-like
licenses.
See LICENSE-APACHE, and LICENSE-MIT for details.