国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

[C#][正則表達式]尋找匹配的Groups的幾種方法

2024-07-21 02:18:51
字體:
來源:轉載
供稿:網友

尋找匹配的groups的幾種方法示例:

//
// 兩種大方法:
// matchcollection<->matches
// match<->match方式
//
// 第一大種:
matchcollection mmcollection =
oregex.matches(strhtmlcontent);
if(mmcollection.count > 1)
{
foreach(match m in mmcollection)
{
group ghiddentonecodes = m.groups["hiddentonecodes"];
strvalue = ghiddentonecodes.value;
}
}

// 第二大種:
// 這里面有兩種方式:
// 第2.1種:nextmacth方式
match mnext;
int posn, length;
for ( mnext = oregex.match( strhtmlcontent ) ; mnext.success ; mnext = mnext.nextmatch() )
{
foreach( group g in mnext.groups )
{
if( g.length != 0 )
{
// position of capture object.
posn = g.index;
// length of capture object.
length = g.length;
strvalue = g.value;
}
}
}
//
// 第2.2種:capturecollection方式
////string[] results = new string[20];
// loop through the match collection to retrieve all
// matches and positions.
match mresult = oregex.match(strhtmlcontent);
if(false == mresult.success)
{
m_strlasterror =
("[parsefile][解析html]錯誤描述:沒有匹配到");
return "";
}
capturecollection cc;
foreach(group g in mresult.groups)
{
// capture the collection for group(i).
cc = g.captures;
for (int j = 0; j < cc.count; j++)
{
// position of capture object.
posn = cc[j].index;
// length of capture object.
length = cc[j].length;
strvalue = cc[j].value;
}
}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 贵溪市| 漾濞| 镇巴县| 项城市| 武穴市| 浮山县| 普安县| 邵阳县| 沧州市| 油尖旺区| 武功县| 乾安县| 平舆县| 上饶县| 二连浩特市| 旬阳县| 静乐县| 无棣县| 肇源县| 漯河市| 仙居县| 扎兰屯市| 固安县| 巨野县| 双峰县| 鸡东县| 韶山市| 九龙城区| 灵璧县| 商南县| 万山特区| 固镇县| 盘山县| 哈密市| 综艺| 宝鸡市| 汶上县| 澜沧| 鄂托克旗| 铜梁县| 米泉市|