// 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"(\d+\.)+[\s\S]+?(?=(\d+\.)+|$)").unwrap();
let string = "56.8. Liaise with the incumbent Service Provider to enable the full completion of the mobilisation period;
56.9. Produce and implement a communications plan , to be agreed with the Client, including the frequency, responsibility for and nature of communication with the Client and end users of the service;
56.10. Produce a mobilisation report for each Affected Property to encompass programmes that will fulfil all the Client’s obligations to landlords and other tenants. The format of reports and programmes shall be in accordance with the Client’s requirements. Particular attention shall be paid to establishing the operating requirements of the occupiers in drawing up these programmes for agreement with the Client;";
// result will be a tuple containing the start and end indices for the first match in the string
let result = regex.captures(string);
let (start, end) = match result {
Some((s, e)) => (s, e),
None => {
// ...
}
};
println!("{}", &string[start, end]);
}
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/