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
> >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
> (match
> >and sed-like replace).
> Doug, I think this is beginning to grow on me a little - I hadn't
> of using operator overloading to simulate the /expression/format/
> 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

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.


Boost list run by bdawes at, gregod at, cpdaniel at, john at