// 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"(\S)[ \t]*(?:\r\n|\n)[ \t]*(\S)").unwrap();
let string = "Random Data, Company
2015
This is a sentence that has line
break in the middle of it due to extracting from a PDF.
How do I support
3 line sentence
breaks please?
HEADER HERE
The first sentence will
match. However, this line will not match
for some reason
that I cannot figure out.
Portfolio:
http://DoNotMatchMeBecauseIHaveAPeriodInMe.com
Full Name
San Francisco, CA
94000
1500 testing a number as the first word in
a broken sentence.
Match sentences with capital letters on the next line like
Wi-Fi.
This line has
trailing spaces after exclamation mark!
";
let substitution = "\\1 \\2";
// 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/