re = /^\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*))/m
str = '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)
{'
# Print the match result
str.scan(re) do |match|
puts match.to_s
end
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 Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html