Lex Program to Check valid Mobile Number (10 Digits)
%{
#include<stdio.h>
%}
%%
[\n] {printf("\n\nEnter mobile Number: ");}
[1-9][0-9]{9} {printf("Mobile number Valid.");}
.* {printf("Mobile number Invalid.");}
%%
int main()
{
printf("\nEnter mobile Number: ");
yylex();
return 0;
}
Output:#include<stdio.h>
%}
%%
[\n] {printf("\n\nEnter mobile Number: ");}
[1-9][0-9]{9} {printf("Mobile number Valid.");}
.* {printf("Mobile number Invalid.");}
%%
int main()
{
printf("\nEnter mobile Number: ");
yylex();
return 0;
}
0 Comments