CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004
    Posts
    15

    Lightbulb Regular Expressions

    Hi,

    I would like to know how I can implement a regular expression
    for the following in C Language...

    Assignment
    For
    Switch

    Please provide me the answer it's urgent
    Thanks in advance

  2. #2
    Join Date
    Jan 2002
    Location
    Scaro, UK
    Posts
    5,940
    Not easily. I tend to build up a parse tree for each character in a string.

    I bet if you search this website as well as www.codeproject.com you'll find a few answers to your question.

    I've implemented regular expression pattern matching before and basically I build up a list of elements with each character being either

    (a) A character
    (b) A control character (wildcard etc).

    Then I use this to attempt to 'match' other strings to it.

    Darwen.
    www.pinvoker.com - PInvoker - the .NET PInvoke Interface Exporter for C++ Dlls.

  3. #3
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150
    If you want a ready made regular expression library, definetly checkout the regex class at http://www.boost.org.
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  4. #4
    Join Date
    Dec 2001
    Location
    Ontario, Canada
    Posts
    2,236
    Regular expressions should be used to tokenize your input. Your syntactical and semantical analyzers should determine if the input is valid. Thus you'll want to tokenize the language into its keywords, not into its statements.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured