fork download
  1. %{
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. %}
  5.  
  6. /*
  7.   This pattern matches a basic email address:
  8.   - One or more letters, digits, dots, underscores, percent signs, plus or minus signs,
  9.   - Followed by an '@',
  10.   - Then one or more letters, digits, dots or hyphens,
  11.   - Followed by a dot and at least two letters.
  12.   Note: Email syntax can be complex; this regex covers many common cases.
  13. */
  14. %%
  15. ^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$ {
  16. printf("Valid email address: %s\n", yytext);
  17. exit(0);
  18. }
  19.  
  20. ^.*$ {
  21. printf("Invalid email address: %s\n", yytext);
  22. exit(1);
  23. }
  24. %%
  25.  
  26. int main(void)
  27. {
  28. yylex();
  29. return 0;
  30. }
  31.  
Success #stdin #stdout #stderr 0.02s 6812KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/mvEz5P/prog:30:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit