re = /^((struct *[a-z0-9_]+)|[a-z0-9_]+) *[*a-z0-9_]+\((void|((((struct *[a-z0-9_]+)|[a-z0-9_]+) *[*a-z0-9_]+)(, ((struct *[a-z0-9_]+)|[a-z0-9_]+) *[*a-z0-9_]+)*))\)/m
str = 'int a_0(void)
int b_1(int a)
int c_2(int a, int b)
void *xmalloc(size_t n)
int main(int argc, char **argv)
void *xmalloc(size_t n)
void release(struct s_block)
int a_(int a, int b)
int main(void)
struct student get_student(char *name)
struct student *grow_2fast(struct student *s, int age_diff)
struct student *grow_2fast(struct student *s, struct hello age_diff)
int main(void)
int print_me(int h1)
/*
**int main(void)
*/'
# 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