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:
- 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
- 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/C++ Program for Longest Increasing Subsequence
- C Program for Longest Palindromic Subsequence | DP-12
- C Program for focal length of a spherical mirror
- 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/C++ Program to find sum of elements in a given array
- C Program to find size of a File
- C Program to find transpose of a matrix
- C/C++ Program to Find sum of Series with n-th term as n^2 - (n-1)^2
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.