Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8107493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:47:36+00:00 2026-06-06T00:47:36+00:00

i am trying to work with a flex generator and how it works,the code

  • 0

i am trying to work with a flex generator and how it works,the code below replaces the the sequence of symbols in a text file {number number} to {“d” ws “d”}, and it calculates the number of replacements

%{
   int count = 0;
%}
DIGIT [0-9]
%%
{DIGIT}{DIGIT} {count++; printf("d d");} 
%%
int main()
{
  yylex();
  printf( "\n#Report: %d changes made!", count);
  return 0;
}
int yywrap()
{
    return 1;
}

After submitting a file with the rules of the input file and compile flex lex.yy.c, received an executable file. The input to the executable file we submit the following data stream

====================test.in============================
wefwe
f
weferg54gfwsfwe
fwef
wefwefwf
wefewf21321dsfredf
sdf
===========================================================

the output obtained

============================test.out==================

wefwe
f
wefergd dgfwsfwe
fwef
wefwefwf
wefewfd dd d1dsfredf
sdf
#Report: 3 changes made!

========================================================

my question is that what if i want to
In the given text to replace the sequence of symbols {consonant consonant} to {consonant «a» consonant} and calculate the number of replacements

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T00:47:39+00:00Added an answer on June 6, 2026 at 12:47 am

    I’m not sure what concept you’re stuck on. Perhaps it’s the idea of writing a character class to match consonants: let’s consider “Y” to be a consonant for this question, and only match lower case letters. Perhaps it’s the question of how to access individual characters of the matched input: one way to do this is to declare yytext to be an %array. At any rate, the code you want is something like this:

    %{
        int count = 0;
        int consonantPatternCount = 0;
    %}
    %array
    DIGIT [0-9]
    CONSONANT [bcdfghjklmnpqrstvwxyz]
    %%
    {DIGIT}{DIGIT} {count++; printf("d d");}
    {CONSONANT}{CONSONANT} { consonantPatternCount++; printf("%c a %c", yytext[0], yytext[1]);} 
    %%
    int main()
    {
          yylex();
          printf( "\n#Report: %d changes made!", count);
          printf("\n#Report: %d consonant changes made", consonantPatternCount);
          return 0;
    }
    int yywrap()
    {
        return 1;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get Flex 3 and OpenX to work together. Everything works great
I'm trying to work out what the best method to passing a large number
I am trying to work with a global variable in Flex and it does
Im currently trying to work the imageSnapshot function in flex. Ive been looking hard
I've been wrestling with trying to get FlexSlider http://flex.madebymufffin.com/ to work with Drupal 7
I am trying to get a xml file with data into Flex application. There
I'm trying to do a file upload in Flex using it's FileReference class. This
i'm trying to add whitespaces in front of my text, but flex removes all
I am trying work out with MERGE statment to Insert / Update Dimension Table
Trying to work with Eclipse for Android (ADT plugin) development at my iMac (2.4Ghz,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.