Lex is a computer program that generates lexical analyzers. Lex reads an input stream specifying the lexical analyzer and outputs source code implementing the lexer in the C programming language.
The commands for executing the lex program are:
lex abc.l (abc is the file name) cc lex.yy.c -efl ./a.out
Let’s see lex program to check valid email.
Input: geeks for geeks Output: 5 Input: facebook google yahoo Output: 8
Below is the implementation:
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- C program to find and replace a word in a File by another given word
- Lex program to find the Length of a String
- C program to find the length of a string
- Lex program to search a word in a file
- Lex program to count the frequency of the given word in a file
- Program to print the Alphabets of a Given Word using * pattern
- Lex code to replace a word with another word in a file
- C Program for Longest Palindromic Subsequence | DP-12
- C/C++ Program for Longest Increasing Subsequence
- C Program for focal length of a spherical mirror
- C program to print the length of a String using %n format specifier
- C Program for Number of jump required of given length to reach a point of form (d, 0) from origin in 2D plane
- C Program for Program to find area of a circle
- C Program to find whether a no is power of two
- C Program to find size of a File
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.