Wymagane są biblioteki BOOST.
kod dla zmiennych AnsiString i string:
KOD cpp: UKRYJ
#include <string>
#include <boost\\regex.hpp>
using namespace boost;
using namespace std;
void __fastcall TForm1::Button1Click(TObject *Sender)
{
AnsiString text = Memo1->Text;
string input = text.c_str();
regex expr("<[^>]*>");
string replace = " ";
string result = regex_replace( input, expr, replace, match_default | format_sed);
Memo1->Text = String( result.c_str() );
}
#include <boost\\regex.hpp>
using namespace boost;
using namespace std;
void __fastcall TForm1::Button1Click(TObject *Sender)
{
AnsiString text = Memo1->Text;
string input = text.c_str();
regex expr("<[^>]*>");
string replace = " ";
string result = regex_replace( input, expr, replace, match_default | format_sed);
Memo1->Text = String( result.c_str() );
}
kod dla zmiennych UnicodeString i wstring przy mapowaniu ustawionym na wchar_t - tylko C++Builder 2009 i wyższe wersje:
KOD cpp: UKRYJ
#include <string>
#include <boost\\regex.hpp>
using namespace boost;
using namespace std;
void __fastcall TForm1::Button1Click(TObject *Sender)
{
String text = Memo1->Text;
wstring input = text.c_str();
wregex expr(L"<[^>]*>");
wstring replace = L" ";
wstring result = regex_replace( input, expr, replace, match_default | format_sed);
Memo1->Text = String( result.c_str() );
}
#include <boost\\regex.hpp>
using namespace boost;
using namespace std;
void __fastcall TForm1::Button1Click(TObject *Sender)
{
String text = Memo1->Text;
wstring input = text.c_str();
wregex expr(L"<[^>]*>");
wstring replace = L" ";
wstring result = regex_replace( input, expr, replace, match_default | format_sed);
Memo1->Text = String( result.c_str() );
}
Szybko i bezboleśnie.