VOOZH about

URL: https://www.geeksforgeeks.org/c/lex-program-to-check-if-characters-other-than-alphabets-occur-in-a-string/

⇱ Lex program to check if characters other than alphabets occur in a string - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Lex program to check if characters other than alphabets occur in a string

Last Updated : 23 Jul, 2025

Problem  :- Write a Lex program to find if a character apart from alphabets occurs in a string or not

Explanation:-  Flex (Fast Lexical Analyzer Generator ) is a tool or computer program which generates lexical analyzers (scanners or lexers) written by Vern Paxson in C around 1987.Lex reads an input stream specifying the lexical analyzer and outputs source code implementing the lexer in the C programming language.

The function yylex() is the main flex function which runs the Rule Section.

Examples.

Input: abcd
Output: No character other than alphabets
Explanation: Since we have alphabets ranging from a to z that's why the output is "no character other than alphabets"
 
Input: abcd54
Output: character other than alphabets present
Explanation: since 5 and 4 are not alphabets
 
Input: abc@bdg
Output: character other than alphabets present
Explanation: since @ is not a alphabet

Below is the implementation program:

Output:

👁 Image
Comment
Article Tags: