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:
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- C program to find and replace a word in a File by another given word
- C program to find the length of a string
- Lex program to find the Length of a String
- Lex program to search a word in a file
- Program to print the Alphabets of a Given Word using * pattern
- Lex program to count the frequency of the given word in a file
- 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
- Program to find absolute value of a given number
- C/C++ Program to Find sum of Series with n-th term as n^2 - (n-1)^2
- C Program to find transpose of a matrix
- C Program to find size of a File
- C Program for Find sum of odd factors of a number
- C Program for Find the perimeter of a cylinder
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.