字符串:
void ABTR("quint32 ab")
{
string s = TR("sky is blue.");
obj.foo(TR('rose is red.'));
obj.foo(TR('rose is red."));
obj.foo(TR("Mike (Mike Lee)say /"He is hungury/""))
}
正则表达式:(?<!/w)(?:TR/()('|")(.*)/1(?:/))
C++ boost:
boost中*贪婪匹配所以后面加了?,C#中则不需要
boost中设计到的正则表达式的类:
namespace boost{ template <class charT, class traits = regex_traits<charT> > class basic_regex; typedef basic_regex<char> regex; typedef basic_regex<wchar_t> wregex; }
表示一个正则表达式
**************
template <class BidirectionalIterator,
class Allocator = std::allocator<sub_match<BidirectionalIterator> >
class match_results;
typedef match_results<const char*> cmatch;
typedef match_results<const wchar_t*> wcmatch;
typedef match_results<string::const_iterator> smatch;
typedef match_results<wstring::const_iterator> wsmatch;
返回一个匹配结果,其中包含由sub_match组成的分组(正则表达式中圆括号内的子表达式为一个分组)
[0]也是一个sub_match表示整个正则表达式所匹配的子串,其中的first,second代表整个子串的开始位置和结束位置。
[1]。。。则为依次的分组
************
template <class BidirectionalIterator>
class sub_match;
typedef sub_match<const char*> csub_match;
typedef sub_match<const wchar_t*> wcsub_match;
typedef sub_match<std::string::const_iterator> ssub_match;
typedef sub_match<std::wstring::const_iterator> wssub_match;
代表一个分组,sub_match继承自std::pair,其中first表示匹配到的字串的起始位置,second为结束位置
sub_match可隐式转换为一个字符串类型
**************
2个函数:
regex_match //完整匹配,整个待匹配串完全符合正则表达式时,返回true
regex_search //部分匹配,找其中匹配的子串
C#