Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2004-10-22 17:42:55


Jonathan Turkanis wrote:
> <Schalk_Cronje_at_[hidden]> wrote in message:
>
>
>>Would anyone be interested in having a perl-like regex shortcut notation?

<snip>

>>// [1] Substitutes first occurrence and copy (calls boost::regex_replace)
>>// perl: ($s2=$str) =~ s/(BLAH)/Hooray/;
>>std::string s2= _s / "(BLAH)" / "Hooray" / str;
>
>
> Something like this would fit in easily with Eric Niebler's xpressive
> library. In fact, I suggested it, but Eric said it was "too cute". Perhaps
> we should convene a focus group to discuss the subject. ;-)
>

In fact, you could use almost completely emulate perl syntax if you want to:

     string str = ...;
     sregex rex = ...;

     str ^= _s/rex/"c++ sux, perl rulz!!"/_g;

It's certainly cute, and it would be an interesting exersice. It is also
not particularly appealing to me, since the only reason I wrote a C++
regex engine in the first place was because I strongly disliked perl's
syntax. And to me, it seems less like a domain-specific embeded language
than like simply trying to write perl in C++ -- an endeavor of dubious
value.

There are many things I need to add to xpressive. This is far, far down
the list, but if someone wanted to submit a patch to xpressive
(including docs and tests!), I wouldn't be opposed to adding it (so long
as it could be cleanly isolated in a nested namespace).

-- 
Eric Niebler
Boost Consulting
www.boost-consulting.com

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