Lex : Check Valid Email

%{
#include<stdio.h>
#include<stdlib.h>
int flag=0;
%}
%%
[a-z . 0-9]+@[a-z]+".com"|".in" { flag=1; }
%%
int main()
{
yylex();
if(flag==1)
printf("Accepted");
else
printf("Not Accepted");
}

/*
Enter input
press Enter & ctrl+d to get output
*/

Output :-
abc@gmail.com
Accepted

Leave a comment