// 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)(S\w.*\d[:])|(([0-9.]+|(-[0-9.]+)))|([A-Z]{2}\b)").unwrap();
let string = "ACTIONS:
[ { LONGITUDES:
{ SHUTTLE_LON_A6: [ 748, [ 'CI', 76.5, 980.5 ] ],
SHUTTLE_LON_A5:
[ 271,
[ 'CL', 0, 76.5 ],
[ 'CI', 76.5, 980.5 ],
[ 'CL', 980.5, 1057 ] ],
SHUTTLE_LON_A4: [ 129 ],
SHUTTLE_LON_A3: [ 107 ],
SHUTTLE_LON_A2: [ -35 ],
SHUTTLE_LON_A1: [ -57 ] },
LATITUDES: { SHUTTLE_LAT_1: [ [ 1057 ] ] } },
{ LONGITUDES:
{ SHUTTLE_LON_A6: [ 978, [ 'CL', 76.5, 980.5 ] ],
SHUTTLE_LON_A5:
[ 727,
[ 'CL', 0, 76.5 ],
[ 'CI', 76.5, 980.5 ],
[ 'CL', 980.5, 1057 ] ],
SHUTTLE_LON_A4: [ 250, [ 'CI', 76.5, 980.5 ] ],
SHUTTLE_LON_A3: [ 20, [ 'CL', 76.5, 980.5 ] ],
SHUTTLE_LON_A2: [ -122 ],
SHUTTLE_LON_A1: [ -144 ] },
LATITUDES:
{ SHUTTLE_LAT_1:
[ [ 20.5, [ 'CI', 0, 1100 ] ],
[ 34.5, [ 'CI', 0, 1100 ] ],
[ 58.5, [ 'CI', 0, 1100 ] ],
[ 76.5,
[ 'CL', 0, 271 ],
[ 'CI', 271, 727 ],
[ 'CL', 727, 1100 ] ],
[ 980.5,
[ 'CL', 0, 271 ],
[ 'CI', 271, 727 ],
[ 'CL', 727, 1100 ] ],
[ 998.5, [ 'CI', 0, 1100 ] ],
[ 1022.5, [ 'CI', 0, 1100 ] ],
[ 1036.5, [ 'CI', 0, 1100 ] ],
[ 1057, [ 'CL', 0, 1100 ] ],
[ 1057 ] ] } } ] } ]";
// 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/