// 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*((public|private|protected)? *(static)? *(void|int|String|boolean|float|double) +[a-zA-Z_](\w)* *[\(] *(((int|String|boolean|float|double) +[a-zA-Z_](\w)*))* *( *, *int +[a-zA-Z_](\w)* *| *, *String +[a-zA-Z_](\w)* *| *, *boolean +[a-zA-Z_](\w)* *| *, *float +[a-zA-Z_](\w)* *| *, *double +[a-zA-Z_](\w)* *|\))+\s*[{]\s*|( *public +static +void +main *\( *String *(\[\])? * args *(\[\])? *\)\s*[{]\s*))").unwrap();
let string = "public static void salud(String hola,boolean siu) {
void ultimo(int hola){
public void saludos(){
void numeros(String cola, int hola, String si){
public static void main(String[] args){
protected String idnombre (int n){
protected void prueba(String a,int b){
public static void main(String[] args[]){
public static void main(String args[]){
void hola(){}
void hola(){
public void main(String id)
{
public void hola ( int c)
{";
// 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/