3,055
社区成员




<div style="width:17cm;margin-left:2cm">
<div id="header" style="font-family:宋体;font-size:10.5pt;line-height:1.7">
<p style="text-align:center"></p>
<p style="text-align:center">
<span style="font-weight:bold">玩的开心</span></p>
<table cellpadding="0" border="0" rules="all" style="width:100%;border:0pt #000000 solid #000000;border-collapse:collapse;empty-cells:show;table-layout:fixed;border-style:solid">
<tr><td style="" colspan="2" Width="41.55%"><p style="line-height: 1.7;">
<span style="font-weight:bold">时间:</span><span style="font-weight:bold">2012-07-16</span></p></td><td style="" colspan="2" Width="58.45%">
<p style="text-align:center;line-height: 1.7;">
<span style="font-weight:bold">不爽:</span><span style="font-weight:bold">很不爽</span></p></td></tr><tr><td style="" Width="22.76%">
<p style="line-height: 1.7;"><span style="font-weight:bold">姓名:</span><span style="font-weight:bold">刘雅</span><span>
</span></p></td><td style="" Width="18.79%"><p style="line-height: 1.7;"><span style="font-weight:bold">性别:</span>
<span style="font-weight:bold">女</span></p></td><td style="" Width="18.79%"><p style="line-height: 1.7;">
<span style="font-weight:bold">年龄:</span><span style="font-weight:bold">17岁</span></p>
</td><td style="" Width="39.65%"><p style="line-height: 1.7;">
CXMLReader xmlReader ;
xmlNodePtr ptrRoot = xmlReader.ParseString(strTmp.c_str(), strTmp.length());
xmlNodePtr ptrSecondNode = xmlReader.GetChildNode(ptrRoot);
while(ptrSecondNode != NULL)
{
if(xmlReader.IsThisNode(ptrSecondNode, strKey))
{
string strValue = "";
xmlReader.GetNodeName(ptrThirdNode,strValue);
strEmrContent += strValue;
}
xmlNodePtr ptrThirdNode = xmlReader.GetChildNode(ptrSecondNode);
while(ptrThirdNode != NULL)
{
if(xmlReader.IsThisNode(ptrSecondNode, strKey))
{
string strValue = "";
xmlReader.GetNodeName(ptrThirdNode,strValue);
strEmrContent += strValue;
}
ptrThirdNode = xmlReader.GetNextNode(ptrThirdNode);
}
ptrSecondNode = xmlReader.GetNextNode(ptrSecondNode);
}
#include <iostream>
#include <string>
#include <regex>
using namespace std;
int main() {
string str("This expression could match from A and beyond. [ expression express ]");
string rs = "exp\\w*"; // 正则字符串,exp开始的单词
cout << str << endl;
regex expression(rs); // 字符串传递给构造函数,建立正则表达式
// regex_match 判断一个正则表达式(参数 e)是否匹配整个字符序列 str. 它主要用于验证文本。
// 注意,这个正则表达式必须匹配被分析串的全部,否则函数返回 false.
// 如果整个序列被成功匹配,regex_match 返回 True.
bool ret = regex_match(str, expression);
if (ret)
cout << "可以匹配整个文本" << endl;
else
cout << "不能匹配整个文本" << endl;
// regex_search 类似于 regex_match, 但它不要求整个字符序列完全匹配。
// 你可以用 regex_search 来查找输入中的一个子序列,该子序列匹配正则表达式 e.
ret = regex_search(str, expression);
if (ret)
cout << "能够搜索到 " << rs << endl;
else
cout << "不能搜索" << endl;
// regex_replace 在整个字符序列中查找正则表达式e的所有匹配。
// 这个算法每次成功匹配后,就根据参数fmt对匹配字符串进行格式化。
// 缺省情况下,不匹配的文本不会被修改,即文本会被输出但没有改变。
str = regex_replace(str, expression, string("表达式"));
// VC2010或者TR1注意:这里第三个参数要用string()转换
// http://www.johndcook.com/cpp_regex.html
// started with C++ TR1 regular expressions
cout << str << endl;
return 0;
}
//This expression could match from A and beyond. [ expression express ]
//不能匹配整个文本
//能够搜索到 exp\w*
//This 表达式 could match from A and beyond. [ 表达式 表达式 ]