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 8929711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:43:54+00:00 2026-06-15T08:43:54+00:00

I have a lex pattern file (test.l) where I want to recognize a pattern

  • 0

I have a lex pattern file (test.l) where I want to recognize a pattern for an IPv4 address and an IPv6 address.

Currently I use a binary pattern notation for example

src -ip of 192.168.156.203 is to be written as 
1 src-ip {11000000 10101000 10011100 11001011} 

where ‘1’ is a tag that I use for classification.I want to extend this patter to include IPv4 address(dotted decimal) and IPv6 address (quad notation)

Currently my the relevant portion of my lexical analyser file (test.l) looks as below.

    BINARY_PATTERN [ \t]*[ \t0-1\-\*]+[ \t]*

    <S_src_ip>\{{BINARY_PATTERN}\}  {

         /*Some code here*/
    }

I have slightly extended the code as below.

<S_dst_ip>\{{BINARY_PATTERN}\}|\{[0-255]\\.[0-255]\\.[0-255]\\.[0-255}\}

to support IPv4 addresses.Is there something wrong with the above code. Also how do I extend this to support IPV6 patterns.

I cannot compile the above code.It is showing

flex --header-file="test.h" test.l 
test.l:50: bad character class

Can someone point out what is the error.

  • 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-15T08:43:55+00:00Added an answer on June 15, 2026 at 8:43 am

    I think I see a typo.

    <S_dst_ip>\{{BINARY_PATTERN}\}|\{[0-255]\\.[0-255]\\.[0-255]\\.[0-255}\}
    

    should be:

    <S_dst_ip>\{{BINARY_PATTERN}\}|\{[0-255]\\.[0-255]\\.[0-255]\\.[0-255]\}
    

    But to go beyond that, I don’t think the character class [0-255] will accomplish what you want. It will match a single digit, 0, 1, 2, or 5.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a lex pattern file (test.l) where I want to recognize a pattern
In my tokenizer (.lex) file I want to match the following pattern : AaBC12/awD41/dfs21
I have created a lex file test.l and create lex.yy.c from it, which I
For the example.l lex file I get the error below. If I comment out
I'd like to use lex/yacc to read in a delimited text file. This would
I have an experimental flex source file(lex.l): %option noyywrap %{ int chars = 0;
I am very new to Lex and Yacc. I have a Lex program. Example:
I am trying to learn Lex. I have a simple program where i want
I want to use a custom converter on the translated content, e.g. I have
I have a relatively simple lex/flex file and have been running it with flex's

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.