GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

No menu could be recovered. Follow the blue links in the page.

This view

  • Original page
  • New address

GeezerVison is showing codebrowser.dev — regex_example.cpp source code [boost/libs/algorithm/string/example/regex_example.cpp] - Codebrowser

Codebrowser logo
About
Contact
1// Boost string_algo library example file ---------------------------------//
2
3// Copyright Pavol Droba 2002-2003. Use, modification and
4// distribution is subject to the Boost Software License, Version
5// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6// http://www.boost.org/LICENSE_1_0.txt)
7
8// See http://www.boost.org for updates, documentation, and revision history.
9
10#include <string>
11#include <iostream>
12#include <iterator>
13#include <boost/regex.hpp>
14#include <boost/algorithm/string/regex.hpp>
15
16using namespace std;
17using namespace boost;
18
19int main()
20{
21 cout << "* Regex Example *" << endl << endl;
22
23 string str1("abc__(456)__123__(123)__cde");
24
25 // Replace all substrings matching (digit+)
26 cout <<
27 "replace all (digit+) in str1 with #digit+# :" <<
28 replace_all_regex_copy( Input: str1, Rx: regex("\\(([0-9]+)\\)"), Format: string("#$1#") ) << endl;
29
30 // Erase all substrings matching (digit+)
31 cout <<
32 "remove all sequences of letters from str1 :" <<
33 erase_all_regex_copy( Input: str1, Rx: regex("[[:alpha:]]+") ) << endl;
34
35 // in-place regex transformation
36 replace_all_regex( Input&: str1, Rx: regex("_(\\([^\\)]*\\))_"), Format: string("-$1-") );
37 cout << "transformad str1: " << str1 << endl;
38
39 cout << endl;
40
41 return 0;
42}
43

source code of boost/libs/algorithm/string/example/regex_example.cpp

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.