// include the latest version of the regex crate in your Cargo.toml
extern crate regex;
use regex::Regex;
fn main() {
let regex = Regex::new(r#"(?mi)^([0-9.]+)\s(.)\s(.)\s\[(.*)\s(\+[0-9]*)\]\s\"GET|POST\""#).unwrap();
let string = "127.0.0.1 - - [11/Sep/2015:08:15:33 +0600] \"GET / HTTP/1.1\" 200 4189
127.0.0.1 - - [11/Sep/2015:08:15:33 +0600] \"GET /icons/blank.gif HTTP/1.1\" 200 148
127.0.0.1 - - [11/Sep/2015:08:15:33 +0600] \"GET /icons/folder.gif HTTP/1.1\" 200 225
127.0.0.1 - - [11/Sep/2015:08:15:33 +0600] \"GET /icons/text.gif HTTP/1.1\" 200 229
127.0.0.1 - - [11/Sep/2015:08:15:33 +0600] \"GET /icons/unknown.gif HTTP/1.1\" 200 245
127.0.0.1 - - [11/Sep/2015:08:15:33 +0600] \"GET /favicon.ico HTTP/1.1\" 404 1207
127.0.0.1 - - [11/Sep/2015:08:15:40 +0600] \"GET /public/ HTTP/1.1\" 200 1023
127.0.0.1 - - [11/Sep/2015:08:15:37 +0600] \"GET /public/ HTTP/1.1\" 200 1023
127.0.0.1 - - [08/Dec/2015:11:22:28 +0600] \"GET /public/index.php HTTP/1.1\" 200 1023
127.0.0.1 - - [08/Dec/2015:11:22:31 +0600] \"GET /favicon.ico HTTP/1.1\" 404 1239
127.0.0.1 - - [08/Dec/2015:11:22:34 +0600] \"GET / HTTP/1.1\" 200 4189
127.0.0.1 - - [08/Dec/2015:11:22:34 +0600] \"GET /icons/blank.gif HTTP/1.1\" 200 148
127.0.0.1 - - [08/Dec/2015:11:22:34 +0600] \"GET /icons/folder.gif HTTP/1.1\" 200 225
127.0.0.1 - - [08/Dec/2015:11:22:34 +0600] \"GET /icons/unknown.gif HTTP/1.1\" 200 245
127.0.0.1 - - [08/Dec/2015:11:22:34 +0600] \"GET /icons/text.gif HTTP/1.1\" 200 229
127.0.0.1 - - [08/Dec/2015:11:22:52 +0600] \"GET / HTTP/1.1\" 200 1023
127.0.0.1 - - [08/Dec/2015:11:23:05 +0600] \"GET / HTTP/1.1\" 200 1023
127.0.0.1 - - [08/Dec/2015:11:23:07 +0600] \"GET /public/index.php HTTP/1.1\" 404 16638
127.0.0.1 - - [08/Dec/2015:11:23:12 +0600] \"GET / HTTP/1.1\" 200 1023
127.0.0.1 - - [08/Dec/2015:11:23:40 +0600] \"GET /auth/ HTTP/1.1\" 301 332
127.0.0.1 - - [08/Dec/2015:11:23:40 +0600] \"GET /auth HTTP/1.1\" 404 16638
127.0.0.1 - - [08/Dec/2015:11:23:45 +0600] \"GET /auth/login HTTP/1.1\" 404 16638
127.0.0.1 - - [08/Dec/2015:11:23:49 +0600] \"GET / HTTP/1.1\" 200 1023
127.0.0.1 - - [08/Dec/2015:11:44:02 +0600] \"GET / HTTP/1.1\" 200 1046
127.0.0.1 - - [08/Dec/2015:12:11:53 +0600] \"GET / HTTP/1.1\" 200 1023
127.0.0.1 - - [29/Dec/2015:10:29:46 +0600] \"GET / HTTP/1.1\" 200 11160
127.0.0.1 - - [29/Dec/2015:10:29:47 +0600] \"GET /_debugbar/assets/stylesheets?1451362463 HTTP/1.1\" 200 196851
127.0.0.1 - - [29/Dec/2015:10:29:47 +0600] \"GET /_debugbar/assets/javascript?1451362459 HTTP/1.1\" 200 348784
127.0.0.1 - - [29/Dec/2015:10:29:48 +0600] \"GET /favicon.ico HTTP/1.1\" 200 -
127.0.0.1 - - [29/Dec/2015:10:30:58 +0600] \"GET /auth HTTP/1.1\" 404 29966
127.0.0.1 - - [29/Dec/2015:10:32:24 +0600] \"GET /_debugbar/open?max=20&offset=0 HTTP/1.1\" 200 289
127.0.0.1 - - [29/Dec/2015:11:08:46 +0600] \"GET /auth/register HTTP/1.1\" 404 28750
127.0.0.1 - - [30/Dec/2015:08:43:01 +0600] \"GET /auth/register HTTP/1.1\" 404 27092
127.0.0.1 - - [30/Dec/2015:08:43:14 +0600] \"GET /_debugbar/assets/stylesheets?1451362463 HTTP/1.1\" 200 196851
127.0.0.1 - - [30/Dec/2015:08:43:14 +0600] \"GET /_debugbar/assets/javascript?1451362459 HTTP/1.1\" 200 348784
127.0.0.1 - - [30/Dec/2015:08:43:15 +0600] \"GET /favicon.ico HTTP/1.1\" 200 -
127.0.0.1 - - [30/Dec/2015:11:51:32 +0600] \"GET / HTTP/1.1\" 200 9902
127.0.0.1 - - [30/Dec/2015:11:51:34 +0600] \"GET /favicon.ico HTTP/1.1\" 200 -
127.0.0.1 - - [30/Dec/2015:12:22:13 +0600] \"GET /auth HTTP/1.1\" 404 28622
127.0.0.1 - - [28/Mar/2016:12:32:18 +0600] \"GET / HTTP/1.1\" 200 9881
127.0.0.1 - - [28/Mar/2016:12:32:38 +0600] \"GET /_debugbar/assets/stylesheets?1451362463 HTTP/1.1\" 200 196851
127.0.0.1 - - [28/Mar/2016:12:32:38 +0600] \"GET /_debugbar/assets/javascript?1451362459 HTTP/1.1\" 200 348784
127.0.0.1 - - [28/Mar/2016:12:32:39 +0600] \"GET /favicon.ico HTTP/1.1\" 200 -
";
let substitution = "";
// result will be a String with the substituted value
let result = regex.replace_all(string, substitution);
println!("{}", result);
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Rust, please visit: https://docs.rs/regex/latest/regex/