
Would anyone be interested in having a perl-like regex shortcut notation? The original idea was born during a local C++ focus group discussion. Looking further into the feasibility I thought that this might be a useful addition to Boost. Possibly something like the following (from some proof-of-concept code) using namespace boost::short_regex; std::string str("And he said: 'BLAH BLAH'"); // [1] Substitutes first occurrence and copy (calls boost::regex_replace) // perl: ($s2=$str) =~ s/(BLAH)/Hooray/; std::string s2= _s / "(BLAH)" / "Hooray" / str; // [2] Substitute globally and copy // perl: ($s2=$str) =~ s/(BLAH)/Hooray/g; s2= _s / "(BLAH)" / "Hooray" / _g / str; // [3] Substitute first occurrence in-place // perl: $str=~ s/(BLAH)/Hooray/; ~_s/ "(BLAH)" / "Hooray" / str; In the above _s and _g are special placeholder/tag objects sort of like _1,_2. Other could include _i (case-insensitive), _m (string as multiple lines) and _s (string as single line). Multiple modifiers can be added using (,) // [4] Substitute globally and copy // perl: ($s2=$str) =~ s/(BLAH)/Hooray/gi; s2= _s / "(BLAH)" / "Hooray" / (_g,_i) / str; The purpose will not be to shortcut all of the boost.regex functionality, just the common cases, as in perl or sed. Cases [1] and [3] is very close to the perl and would be easy to understand, however [2] and [4] is moving away from perl-syntax. This might be considered illegible by some.