Anonymous user
Regular expressions: Difference between revisions
→{{header|C++}}: Edited to reflect usage of C++11's regex, but kept a Boost.Regex blurb for C++03 and earlier
(Regular expressions en FreeBASIC) |
(→{{header|C++}}: Edited to reflect usage of C++11's regex, but kept a Boost.Regex blurb for C++03 and earlier) |
||
Line 586:
=={{header|C++}}==
{{works with|g++|4.0.2}} (may need to be retested?)
Standards earlier than C++11 can make use of Boost's Regex library via boost/regex.hpp
<lang cpp>#include <iostream>
#include <string>
#include <iterator>
#include <
int main()
{
std::string s = "Hi, I am a string";
// match the complete string
if (
std::cout << "The string matches.\n";
else
Line 606:
// match a substring
if (
{
std::cout << "Matched " << match.length()
Line 622:
// replace a substring
std::string dest_string;
s.begin(), s.end(),
re2,
|