當前位置:成語大全網 - 書法字典 - 數據表字典匹配

數據表字典匹配

家裏電腦沒有vs,但是寫作基本可行。首先,用正則表達式匹配字符串以獲得所有符合要求的信息,然後對數據進行操作。

正則表達式分為三部分,ip mac動態。

首先匹配所有符號需求的組合,然後在遍歷集合的過程中匹配ip和mac,並將它們添加到datatable中。

都是用手敲的,難免出錯,但方法沒什麽大問題。

string strtmp =“Interface:192.168 . 4 . 11-0x 10003 Internet地址物理地址類型192.168.1.6 5438+0 00-22-aa-8d-9a-05動態192。654338

strip reg =“((2【0-4】\ d | 25【0-5】|【01?\d\d?)\.){ 3 }(2【0-4】\ d | 25【0-5】|【01?\d\d?) ";

string strmacreg =“(【0-9a-fA-F】{ 2 })((【/\ s:-】【0-9a-fA-F】{ 2 }){ 5 })“;

Regx reg = new Regx(strip reg+strmacreg+“dynamic“);

MatchCollection匹配= reg。匹配項(strtmp);

數據集ds =新數據集();

DataTable dt = new DataTable();

Regx ipreg = new Regx(strip reg。trim());

Regx ipreg = new Regx(strmacreg。trim());

for(int CTR = 0;ctr <。火柴。數數;ctr++)

{

DataRow dr = new DataRow();

dr【0】= IP reg。matches(matches【CTR】。值)【0】。價值;

dr【0】= macreg。matches(matches【CTR】。值)【0】。價值;

dt。rows . Add(dr);

}

ds。add(dt);