- 论坛徽章:
- 14
|
本帖最后由 reb00t 于 2014-08-28 21:37 编辑
蹩脚php来了。。- <?php
- $f = fopen ("200.txt", "r");
- while ($line= fgets ($f)) {
- if(preg_match('/0x00000005/', $line)){
- $mac=explode("\"", $line);
- $pa1='/:/';
- $newmac=preg_replace($pa1, "", $mac[3]);
- $newmac="12345".$newmac;
- print $line;
- }elseif (preg_match('/0x00000019/', $line)) {
- $pa2='/\"\"/';
- print preg_replace($pa2, "\"$newmac\"", $line);
- }else{
- print $line;
- }
-
-
- }
- fclose ($f);
- ?>
- 结果:
- obj.id = "0x00000005" ; obj.value = "08:AC:86:1E:98:43";
- obj.id = "0x00000006" ; obj.value = "08:AC:86:1E:98:46";
- obj.id = "0x00000019" ; obj.value = "1234508AC861E9843";
- obj.id = "0x00000020" ; obj.value = "08:AC:86:1E:98:21";
- [Finished in 1.9s]
- 操作文本:
- obj.id = "0x00000005" ; obj.value = "08:AC:86:1E:98:43";
- obj.id = "0x00000006" ; obj.value = "08:AC:86:1E:98:46";
- obj.id = "0x00000019" ; obj.value = "";
- obj.id = "0x00000020" ; obj.value = "08:AC:86:1E:98:21";
复制代码 |
|