// 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)^(?:#JSGF) (?<version>V1.0) (?<encoding>[A-Z-0-9]+) (?<locale>[a-z]{2}-[A-Z]{2});$").unwrap();
let string = "#JSGF V1.0 UTF-8 hu-HU;
grammar planmaster.hu;
<command_change_odontogram> = ( <change_to> [ a ] <odontogram_mode> [ felvételére | felvételre ] ) | ( <odontogram_mode> felvétele ) ;
<change_to> = ( váltás | válts | menj | ugrás | ugorj ) ;
<odontogram_mode> = ( státuszra | státuszhoz | státusz ) {state} | ( kezelés | kezelésre | kezeléshez | lépésekre | lépésekhez ) {treatment} ;
<command_full_jaw> = <all> * ( alsó {lower} | felső {upper} ) [ fogsor | állkapocs | fogak | fog ] <all> * <status> ;
<all> = mind | összes | teljes ;
<status> = ( <status1> | <status2> | <status3> ) {status} ;
<status1> = ( ép | alaphelyzet | alaphelyzetbe ) {1} ;
<status2> = ( hiány | hiányzik ) {2} ;
<status3> = [ szekunder ] ( szuvas | szuvasodott | szuvasodás ) {3} ;
<tooth18> = ( 18as | 18-as | tizennyolcas | nyolcas | ( 18 as ) ) {18} ;
<tooth17> = ( 17es | 17-es | tizenhetes | hetes | ( 17 es ) ) {17} ;
<tooth16> = ( 16os | 16-os | tizenhatos | hatos ) {16} ;
<tooth_region> = ( bal {left} | jobb {right} ) ( felső {upper} | alsó {lower} ) ;
<tooth_number> = ( <tooth18> | <tooth17> | <tooth16> | és ) ;
<command_select> = ( ( <tooth_number> + ) | <tooth_region> <tooth_number> + ) [ fog | fogak ] ;
";
// 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/