現在、VC++ 2010 を使用していますが、syntax_option_type
VC++ 2010 には次のオプションしか含まれていません。
static const flag_type icase = regex_constants::icase;
static const flag_type nosubs = regex_constants::nosubs;
static const flag_type optimize = regex_constants::optimize;
static const flag_type collate = regex_constants::collate;
static const flag_type ECMAScript = regex_constants::ECMAScript;
static const flag_type basic = regex_constants::basic;
static const flag_type extended = regex_constants::extended;
static const flag_type awk = regex_constants::awk;
static const flag_type grep = regex_constants::grep;
static const flag_type egrep = regex_constants::egrep;
perl_syntax_group は含まれていません (Boost Library にはオプションがあります)。ただし、Boost ライブラリは使用したくありません。
Perl で書かれた正規表現はたくさんあるので、既存の Perl 正規表現ECMAScript
(または VC++ 2010 がサポートする任意のもの) に変換したいと考えています。変換後、サードパーティのライブラリを使用せずに、同等の正規表現を VC++ 2010 で直接使用できます。
一例:
const boost::tregex e(__T("\\A(\\d{3,4})[- ]?(\\d{4})[- ]?(\\d{4})[- ]?(\\d{4})\\z"));
const CString human_format = __T("$1-$2-$3-$4");
CString human_readable_card_number(const CString& s)
{
return boost::regex_replace(s, e, human_format);
}
CString credit_card_number = "1234567887654321";
credit_card_number = human_readable_card_number(credit_card_number);
assert(credit_card_number == "1234-5678-8765-4321");
上記の例でやりたいことは、式をスタイルに変換するe
ことformat
ですECMAScript
。
ECMAScript
すべての Perl 正規表現をスタイルに変換する一般的な方法を見つけることは可能ですか? これを行うためのツールはありますか?
どんな助けでも大歓迎です!