lex program to find words beginning and ending with a

 

 

%{
#include<stdio.h>
%}
%%
(a|A)[a-z]*[0-9]*(a|A)    {printf(“matching”);}
(a|A)+    {printf(“matching”);}
.*    {printf(“not matching”);}
%%
main()
{
yylex();
return 0;
}
int yywrap()
{
}

Sample output

anna
matching
asssdf
not matching

Leave a Reply

Your email address will not be published. Required fields are marked *