// 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)(?P<type>SLA)(?:::)(?P<sa>[0-9]{4,7}|(?:_))?(?:::)(?P<cid>[a-zA-Z-0-9-/._]{8,}|(?:_))?(?:::)(?P<ip>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|(?:_))?(?:::)(?P<desc>[\w#()/-]*)").unwrap();
let string = "SLA::3223453::801-4259::10.224.0.88::PIONEERLAND_DASSEL
SLA::3223482::_::_::PIONEERLAND_RAYMOND
UNI::3238811::ROCHESTER_COMMUNITY_COLLEGE
SLA::_::_::10.224.0.88::PIONEERLAND_WILLMAR_DC
SLA::3211691::A1Q0041C::_::TMOBILE_511_PARK_AVE
SLA::3206176::EEVC/011439//2636/EPL::10.252.51.50::CHARTER_BANK
SLA::3206176::_::10.252.51.50::CHARTER_BANK
SLA::3223621::70.VLXP.024011..CBCL..::_::GOEBEL_FIXTURES_COMPANY
SLA::3178253::KRE1/50393/MPT/CTTNMNTMOB1::10.224.0.88::TMOBILE_COTTON
ACCESS::DSLAM_TEST
SLA::3265812::L2XN/77798/MPT/LRTOMNARPF::10.224.0.159::CCI_ARROWHEAD_PROMOTION
SLA::3152953::180-361-0266::10.252.51.101::HORMEL_BLOOMING_PRAIRIE
SLA::3137605::GEYX/065858::10.252.2.203::ZAYO_VZW_KIMBALL
SLA::3171637::88/INFR/102977//DCE/::10.252.2.25::BNC_BANK
SLA::3182788::150-368-0293::10.252.51.36::NORTHFIELD-HOSPITAL
SLA::3221907::EVENT_41767_PEARL_LAKE_LIT::10.224.0.166::VZW_PEARLLAKE
SLA::_::_::_::VZW_GP_RED_WING_WEST
SLA::3227386::16-KFLA-01156--NVP::_::ZAYO_DULUTH_GROUP";
// 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/