-
Notifications
You must be signed in to change notification settings - Fork 471
Closed
Labels
Description
I wrote the below code to find the use name in the text:
hi
user name: Rusty;
Which is in this case Rusty
located betweenuser name
and the ;
use regex::Regex;
fn main(){
let re = Regex::new(r"(?<=(user name:))?P<name>[A-Za-z0-9\n\s\t]*(?=(;))").unwrap(); // (?<=Description)([^\n]*\n+)+(?=Issued by)
let text = "hi\user name: Rusty;";
let caps = re.captures(text).unwrap();
println!("Use name: {}", &caps["name"]);
}
But I got this error:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Syntax(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
regex parse error:
(?<=(my name:))?P<name>[A-Za-z0-9\n\s\t]*(?=(;))
^^^^
error: look-around, including look-ahead and look-behind, is not supported
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
)', src\main.rs:4:78
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: process didn't exit successfully: `target\debug\server.exe` (exit code: 101)