Boost logo

Boost Users :

From: John Maddock (john_at_[hidden])
Date: 2008-03-19 05:41:37


Jeff wrote:
> Dear Regex Users:
>
> I'd like to know if it is possible to check multiple expressions and
> specify multiple patters within a single regex_replace statement.
> For example, I want to replace .html extensions with .php and replace
> .gif with the .srf extension
>
> Match: http://localhost/index.gif
> replace with: http://localhost/index.srf
>
> Match: http://localhost/index.html
> replace with: http://localhost/index.php
>
> Can this be done within a single regex_replace statement? Although
> this does not work, it demonstrates what I am trying to achieve:

Yep, use "(.gif)|(.html)" as the expression and "(?1.srf:.php)" as the
format string along with the match_flag format_all when calling
regex_replace. The ?1 is a conditional replacement: see
http://svn.boost.org/svn/boost/trunk/libs/regex/doc/html/boost_regex/format/boost_format_syntax.html

HTH, John.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net