// 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#"(?m)calypso:calypsoObject.{10,150}xsi:type="calypso:(\w{2,50})"#).unwrap();
let string = "<calypso:calypsoDocument xmlns:datauploader=\"http://www.calypso.com/datauploader\" xmlns:ftp=\"http://www.calypso.com/ftp\" xmlns:liquidityrule=\"http://www.calypso.com/liquidityrule\" xmlns:bloomberg=\"http://www.calypso.com/bloomberg\" xmlns:liquiditycriteria=\"http://www.calypso.com/liquiditycriteria\" xmlns:pricingscript=\"http://www.calypso.com/pricingscript\" xmlns:am=\"http://www.calypso.com/am\" xmlns:liquidityposition=\"http://www.calypso.com/liquidityposition\" xmlns:scriptableOTC=\"http://www.calypso.com/scriptableOTC\" xmlns:pricingsheet=\"http://www.calypso.com/pricingsheet\" xmlns:matching=\"http://www.calypso.com/matching\" xmlns:scheduler=\"http://www.calypso.com/scheduler\" xmlns:ns20=\"http://www.calypso.com/HedgeAccounting\" xmlns:liquidityreporting=\"http://www.calypso.com/liquidityreporting\" xmlns:taskstation=\"http://www.calypso.com/taskstation\" xmlns:kpiservice=\"http://www.calypso.com/kpiservice\" xmlns:liquiditycore=\"http://www.calypso.com/liquiditycore\" xmlns:calypso=\"http://www.calypso.com/xml\" xmlns:assumption=\"http://www.calypso.com/assumption\" xmlns:liquidityclassification=\"http://www.calypso.com/liquidityclassification\" xmlns:collateral=\"http://www.calypso.com/collateral\" xmlns:calculationserver=\"http://www.calypso.com/calculationserver\" xmlns:bondexoticnote=\"http://www.calypso.com/bondexoticnote\"><calypso:calypsoObject xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"calypso:FutureCommodity\" version=\"14-0\" action=\"SAVE\"><calypso:identification><calypso:versionedIdentifier version=\"0\" code=\"21866845\" codifier=\"CPSLIVE\"/></calypso:identification><calypso:definition><calypso:contract><calypso:type>com.calypso.tk.product.FutureContract</calypso:type><calypso:separator>#</calypso:separator><calypso:identifier code=\"USD#LME#LMEZinc\" codifier=\"convention\"/><calypso:calypsoBusinessKey><calypso:propertyName>currency</calypso:propertyName><calypso:propertyValue>USD</calypso:propertyValue></calypso:calypsoBusinessKey><calypso:calypsoBusinessKey><calypso:propertyName>exchange</calypso:propertyName><calypso:propertyValue>LME</calypso:propertyValue></calypso:calypsoBusinessKey><calypso:calypsoBusinessKey><calypso:propertyName>name</calypso:propertyName><calypso:propertyValue>LMEZinc</calypso:propertyValue></calypso:calypsoBusinessKey></calypso:contract><calypso:expirationDate>2023-10-30Z</calypso:expirationDate><calypso:firstDeliveryDate>2023-10-30Z</calypso:firstDeliveryDate><calypso:firstNotificationDate>2023-10-30Z</calypso:firstNotificationDate><calypso:lastDeliveryDate>2023-10-30Z</calypso:lastDeliveryDate><calypso:lastNotificationDate>2023-10-30Z</calypso:lastNotificationDate><calypso:tradingEndDate>2023-10-30Z</calypso:tradingEndDate><calypso:tradingStartDate>2023-10-30Z</calypso:tradingStartDate><calypso:ccpDate>2023-10-30Z</calypso:ccpDate></calypso:definition></calypso:calypsoObject></calypso:calypsoDocument>";
// 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/