DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Count Email Address
// description of your code here
/*
flex count.l; cc lex.yy.c -lfl -o count
*/
%{
int num_lines = 0, num_addr = 0;
%}
%%
\n ++num_lines;
[a-z0-9]+([_\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\.[a-z]{2,} {
++num_addr;
}
. ;
%%
main() {
yylex();
printf( "# of lines = %d, # of addresses = %d\n",
num_lines, num_addr);
return 0;
}
/* EOF */





