// 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#"(?i)\<\%[\w \@\=\.\*\,\"\$\#\!\&\(\)\/\/\n\+\;\:]*"#).unwrap();
let string = "<%@ page import=\"java.io.*,java.util.*\" %>
<html>
<head>
<title>Auto Refresh</title>
</head>
<body>
<fieldset style=\"width:20%; background-color:#e6ffe6;\">
<legend>Auto refresh</legend>
<h2>Auto Refresh Example</h2>
<%
// Set refresh, autoload time as 1 seconds
response.setIntHeader(\"Refresh\", 1);
// Get current time
Calendar calendar = new GregorianCalendar();
String am_pm;
int hour = calendar.get(Calendar.HOUR);
int minute = calendar.get(Calendar.MINUTE);
int second = calendar.get(Calendar.SECOND);
if(calendar.get(Calendar.AM_PM) == 0)
am_pm = \"AM\";
else
am_pm = \"PM\";
String CT = hour+\":\"+ minute +\":\"+ second +\" \"+ am_pm;
out.println(\"Crrent Time: \" + CT + \"\\n\");
%>
</fieldset>
</body>
</html>";
// 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/