Boost logo

Boost :

From: gregod_at_[hidden]
Date: 2001-07-26 07:30:54


--- In boost_at_y..., John Maddock <John_Maddock_at_c...> wrote:
>
> > I've been toying around with an alternate, more concise
syntax for
> common
> >regular expression operations. Perl is a personal favorite for
string
> >manipulation, so I've partially mimicked its syntax as an add-on
module to
>
> >regex. I rarely find that I require more than these simple
operations
> (match
> >and sed-like replace).
>
> Doug, I think this is beginning to grow on me a little - I hadn't
thought
> of using operator overloading to simulate the /expression/format/
perl
> syntax, I would be interested if there are any perl guru's around
here, and
> what they think.
>
> BTW you could extend the operator overloading a little to handle
strings as
> arguments (as well as precompileed regex's), I wonder if it's
possible to
> to overload operator=~ or failing that a binary operator~, or
failing that
> how about operator>> for the string part:
>
> boost success = mystring >> myregex
> std::string s = mystring >> myregex/myformat
>
> I'm not sure if this is better or worse though...
>
>
> - John Maddock
> http://ourworld.compuserve.com/homepages/john_maddock/

I thought about trying to mimic some of the syntax exactly, i.e.,
result = (str =~ s/str/fmt/g);

but unfortunately we can't overload operator= for
std::basic_String<Char, Traits>, so it isn't going to happen.

The >> operator approach is reasonable. It seems to read as: "feed
mystring into regex" and "feed mystring into regex and replace with
myformat", respectively. I can live with that.

        Doug


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk