// 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)(Dim|Static)(?: )([\S]*)(\(\))?(?: )?(As)? ?(New)? ?([^\r\t\f\v,]*)(,[\S\s][^\n]*)?").unwrap();
let string = "
On Error GoTo Err
Dim obj_AccessApp As Object, Test As xxxy, euaou sai xxx
Set obj_AccessApp = Nothing
Set db_Ref = Nothing
Dim hWndMain As LongPtr
hWndMain = FindWindowEx(0&, 0&, \"OMAIN\", vbNullString)
Do While hWndMain <> 0
Call z_mGetObjectFromHwnd(hWndMain, obj_AccessApp)
Dim str_DbName As String
str_DbName = \"\"
On Error Resume Next
str_DbName = obj_AccessApp.CurrentDb.Name
On Error GoTo Err
If str_DbName Like \"*\\PPMSupportDb.accdb\" Then
On Error Resume Next
obj_AccessApp.CloseCurrentDatabase
obj_AccessApp.Quit
Set obj_AccessApp = Nothing
On Error GoTo 0
Debug.Print \"Support item killed\"
End If
If str_DbName = \"\" Then
On Error Resume Next
obj_AccessApp.Quit
Set obj_AccessApp = Nothing
On Error GoTo Err
Debug.Print \"Blank item killed\"
End If
hWndMain = FindWindowEx(0&, hWndMain, \"OMAIN\", vbNullString)
Loop
Exit_Default:
Set obj_AccessApp = Nothing
Exit Sub
Err:
MsgBox \"GetDatabaseNames\" & vbCrLf & vbCrLf & \"Err = \" & Err.Number & vbCrLf & \"Description: \" & Err.Description
Resume Exit_Default
";
// 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/