// 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#"\"SELECT([^"]|\n|\"[^";]*\")*LIMIT([^"]|\n|\"[^";]*\")*\";"#).unwrap();
let string = "// blah
$SelQuery = \"SELECT DISTICNT C.firstname,C.lastname,C.id as clientid,QC.category_name,QR.cid,QR.catid,QR.rhid
FROM cms_question_report QR, cms_clients C,cms_questioncategory QC ,cms_reporthistory RH
WHERE C.id=QR.cid
AND QR.rhid=RH.id
AND QR.catid='\".$objArray['catid'].\"'
AND QR.catid=QC.id
AND C.id IN($SelClids)
LIMIT $page_no,$this->Limit\";
$SelQuery = \"SELECT DISTICNT C.firstname,C.lastname,C.id as clientid,QC.category_name,QR.cid,QR.catid,QR.rhid
FROM cms_question_report QR, cms_clients C,cms_questioncategory QC ,cms_reporthistory RH
WHERE C.id=QR.cid
AND QR.rhid=RH.id
AND QR.catid='\".$objArray['catid'].\"'
AND QR.catid=QC.id
AND C.id IN($SelClids)\";
\"SELECT LIMIT\";
LIMIT
";
// result will be an iterator over tuples containing the start and end indices for each match in the string
let result = regex.captures_iter(string);
for mat in result {
println!("{:?}", mat);
}
}
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/