From -6279249785626617162
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,ee5799d644d099ed
X-Google-Attributes: gidf78e5,public
From: mottl@miss.wu-wien.ac.at (Markus Mottl)
Subject: Re: Regex-class that works with STL
Date: 1998/01/15
Message-ID: <69ku57$g8q@cantine.wu-wien.ac.at>#1/1
X-Deja-AN: 316414512
References: <69fnmm$ini@cantine.wu-wien.ac.at>
X-Original-Date: 15 Jan 1998 12:07:03 GMT
Originator: austern@isolde.mti.sgi.com
Organization: University of Economics and Business Administration, Vienna, Austria
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBVAwUBNL7Kd0y4NqrwXLNJAQGIhAH+JfEBn9Imj877tBpJ7QCj/rIzxw2WJSXm wYA4jpSWjyo26lpOZyzKhOYjr4p42OsNvgLZYn1Ezy+HAo+6U0dhWw== =daam
Newsgroups: comp.std.c++


In answer to Peter's mail (peter.milliken@gecms.com.au):

> Perhaps I am missing the point, but at least with regular expression
> capability, have you looked at Flex? It generates a C++ class and
> contains the support for easy definition of regular expressions etc.

You are right, Flex is a wonderful tool for specifying regular expressions
and I like using it for implementing large scanners.

Still, there are several problems with it:

- It cannot use regular expressions which are generated at runtime.
- It cannot read from (STL) strings (you'd have to use strstreams or
  the like as intermediate objects :-( ).
- You have to construct a whole scanner class for every different source
  of input, which adds quite some complexity to your code and is probably
  unnecessary if you just want to match a single pattern.
- Maybe you just want to know whether some input matches a pattern
  without having to manipulate the input (extract the matched string).
  e.g.:

    Regex my_regex = "(blabla)+";
    string my_string;
    some_stream >> my_string;
    if (my_string == my_regex) ... // operator== tries to match pattern...

It is not just a matter of matching input, but you might also want to
substitute regular expressions in strings, for example. A Regex-class
in the STL would really come handy...

         Regards,
            Markus

--
*  Markus Mottl              |  University of Economics and       *
*  Department of Applied     |  Business Administration           *
*  Computer Science          |  Vienna, Austria                   *
*  mottl@miss.wu-wien.ac.at  |  http://miss.wu-wien.ac.at/~mottl  *
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu 
]



