// 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"(>\\\${}((.*))<)").unwrap();
let string = "<soapenv:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns=\"http://www.neustar.biz/clearinghouse/SOAPRequestHandler/1.0\">
<soapenv:Header/>
<soapenv:Body>
<ns:processSync soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">
<in0 xs:type=\"type:string\" xmlns:xs=\"http://www.w3.org/2000/XMLSchema-instance\"><![CDATA[<?xml version=\"1.0\" encoding=\"UTF-8\"?><header>
<Request value=\"SOARequest\"/>
<Subrequest value=\"SvCreateRequest\"/>
<CustomerIdentifier value=\"PAT_TST\"/>
<Supplier value=\"NEUSTAR\"/>
<InterfaceVersion value=\"1_0\"/>
<UserIdentifier value=\"example\"/>
<UserPassword value=\"example\"/>
<ApplyBusinessRules value=\"Y\"/>
<Action value=\"submit\"/>
</header>]]></in0>
<in1 xs:type=\"type:string\" xmlns:xs=\"http://www.w3.org/2000/XMLSchema-instance\"><![CDATA[<?xml version=\"1.0\" encoding=\"UTF-8\"?><SOAMessage>
<UpstreamToSOA>
<UpstreamToSOAHeader>
<InitSPID value=\"XS11\"/>
<OID value=\"242424249\"/>
<DateSent value=\"06-19-2017-080000AM\"/>
<SvType value= \"Wireline\"/>
<Action value=\"submit\"/>
</UpstreamToSOAHeader>
<UpstreamToSOABody>
<SvCreateRequest>
<Subscription>
<Tn value=${Tn}/>
</Subscription>
<LnpType value=\"lspp\"/>
<Lrn value=\"4444787878\"/>
<NewSP value=\"XS11\"/>
<AccountId value=\"09040820157163815095\"/>
<AccountName value=\"HIMANSHUTHKNMUAWVF\"/>
<OldSP value=\"XS22\"/>
<SvType value=\"Wireline\"/>
<MMSURI value=\"-\"/>
<NewSPDueDate value=\"11-29-2017-1100PM\"/>
<PortToOriginal value=\"0\"/>
</SvCreateRequest>
</UpstreamToSOABody>
</UpstreamToSOA>
</SOAMessage>]]></in1>
</ns:processSync>
</soapenv:Body>
</soapenv:Envelope>";
// 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/