%{
#include <stdio.h>
#include <string.h>
%}
%%
^[+]?[0-9]{1,4}[\s-]?[0-9]{10}$ {
printf
("Valid Mobile
Number: %s\n", yytext);}
[a-zA-Z_][a-zA-Z0-9_]* {
printf("Valid Identifier: %s\n", yytext);
}
^(https?|ftp):\/\/[^\s\/$.?#].[^\s]*$ {
printf("Valid URL: %s\n", yytext);
}
^(0[1-9]|[12][0-9]|3[01])\/(0[1-9]|1[0-2])\/[0-9]{4}$ {
printf("Valid Date: %s\n", yytext);
}
^(0[0-9]|1[0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$ {
printf("Valid Time: %s\n", yytext);
}
.|\n { /* Ignore other inputs */ }
%%
int main() {
printf("Enter text to validate (Ctrl+D to end):\n");
yylex();
return 0;
}
JXsKI2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdHJpbmcuaD4KJX0KCiUlCgpeWytdP1swLTldezEsNH1bXHMtXT9bMC05XXsxMH0kIHsKICAgIHByaW50ZigiVmFsaWQgTW9iaWxlIE51bWJlcjogJXNcbiIsIHl5dGV4dCk7Cn0KClthLXpBLVpfXVthLXpBLVowLTlfXSogewogICAgcHJpbnRmKCJWYWxpZCBJZGVudGlmaWVyOiAlc1xuIiwgeXl0ZXh0KTsKfQoKXihodHRwcz98ZnRwKTpcL1wvW15cc1wvJC4/I10uW15cc10qJCB7CiAgICBwcmludGYoIlZhbGlkIFVSTDogJXNcbiIsIHl5dGV4dCk7Cn0KCl4oMFsxLTldfFsxMl1bMC05XXwzWzAxXSlcLygwWzEtOV18MVswLTJdKVwvWzAtOV17NH0kIHsKICAgIHByaW50ZigiVmFsaWQgRGF0ZTogJXNcbiIsIHl5dGV4dCk7Cn0KCl4oMFswLTldfDFbMC05XXwyWzAtM10pOihbMC01XVswLTldKTooWzAtNV1bMC05XSkkIHsKICAgIHByaW50ZigiVmFsaWQgVGltZTogJXNcbiIsIHl5dGV4dCk7Cn0KCi58XG4geyAvKiBJZ25vcmUgb3RoZXIgaW5wdXRzICovIH0KCiUlCgppbnQgbWFpbigpIHsKICAgIHByaW50ZigiRW50ZXIgdGV4dCB0byB2YWxpZGF0ZSAoQ3RybCtEIHRvIGVuZCk6XG4iKTsKICAgIHl5bGV4KCk7CiAgICByZXR1cm4gMDsKfQo=