ホームページ >バックエンド開発 >PHPチュートリアル >正規表現関連の質問について、ありがとうございます。

正規表現関連の質問について、ありがとうございます。

WBOY
WBOYオリジナル
2016-06-13 12:19:501039ブラウズ

关于正则表达式的问题,非常感谢!
以下为抓取到的页面,想通过正则表达式函数取出里边的关于教师课表安排的信息,希望各位大侠给帮忙,谢谢。
HTTP/1.1 200 OK
Connection: close
Date: Thu, 07 May 2015 07:44:28 GMT
Server: YxlinkWAF        
X-Powered-By: ASP.NET
X-AspNet-Version: 1.1.4322
Cache-Control: private
Content-Type: text/html; charset=gb2312
Content-Length: 11062


041ad7fc30da077be25be2fb37cf74f4
624bfb4ec09a11699ae206e31263135d
ef1cac8df639bc9110cb13b8b5ab3dd7
b2386ffb911b14667cb8f0f91ea547a7现代教学管理信息系统6e916e0f7d1e588d4f442bf645aedb2fd9529ee4bc533df84e471c414c74feb7
52e4606f1fefc8ac5b952812320513d6
77c8ef62b68b5a2d5956fe59f6d71776
6c3fd152e2b599d357c1baae6956cee2
9b956c85657da06df6e0ce86f30491df
ab72510108c1685386508d5f00486c4a
673a891189a834ff4c34e52e83f28bce
e3eb373c54143356e2f3eb3566e527cc
0cb25d90381a2d15423c186ac25bc7d0
f89674db2848f8f3eb1ad151a7384f86
11061a42168eb19d48647792e9c4b011
0b871fa4456b376bd4162a902fce3fc92cacc6d41bbb37262a98f745aa00fbf0
d6b93be1ee2a078219792f4180a65e76   
function  PutSettings()   
{  try{
factory.printing.header="";   
factory.printing.footer="";   
factory.printing.portrait=true;
}catch(e){}   

 }

2cacc6d41bbb37262a98f745aa00fbf0
c9ccee2e6ea535a969eb3f532ad9fe89 @media Print { .bgnoprint { }
.noprint { DISPLAY: none }}
531ac245ce3e4fe3d50054a55f265927
34934661d7147ca926b095899343bad0
161ac3ed353ec70e2a0b382ed425720b
45febc5d5d3b12d56ac62034781e2edb
9572cdfa094ffb0c87adf52aa40c3069
44d5ef9fba4af5625facccc7f2e21af4
2f3bea9c62a9550c08276d61db668177
2a852685029d0c03b1acf6b5a2a8b5cf
5a56727ccf4a5ec0890cd0d98da70ac8

89a8457d1fc7e662857e1a447c971196
e0a7fa3e7543688422d3f27ab3261bd7 -1) {
theform = document.Form1;
}
else {
theform = document.forms["Form1"];
}
theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
theform.__EVENTARGUMENT.value = eventArgument;
theform.submit();
}
// -->
2cacc6d41bbb37262a98f745aa00fbf0

001952dc96bff3cb3032ddab085dfaed
e5f1e4a17e106b78dffe755200cd4cb516b28748ea4df4d9c2150843fecfba68
12fc3daf37186140c5752c61bce1e19b
181be5ba278f2fb09cb627001d0e871d
学年:
d154ab02cc55ce481a994a8c77e3ebcb
730e644a3eb738dc4d3db9b91e0bb02b2014-20154afa15d3069109ac30911f04c56f3338
77eaabe7609641a7617dc42f85863fee2013-20144afa15d3069109ac30911f04c56f3338
0d53e29f9bb41e945b82c89fdbba35e72012-20134afa15d3069109ac30911f04c56f3338
cc5286289d37a6074fb87c720b408a332011-20124afa15d3069109ac30911f04c56f3338
14d7fe4cba21371966fed0233da9e10b2010-20114afa15d3069109ac30911f04c56f3338
c50e96f8c68b90bf4ab06137782d3f4c2009-20104afa15d3069109ac30911f04c56f3338
1f2291d6d4bd865fd45fad55cd8ffa3c2008-20094afa15d3069109ac30911f04c56f3338
0a3b7ebdba3de09fab5bcf53dde3d37f4afa15d3069109ac30911f04c56f3338

18bb6ffaf0152bbe49cd8a3620346341学期:
9cee3f80ba83a762a11e7034d9c4c8ff
a80305f46bef581019281680f124979124afa15d3069109ac30911f04c56f3338
aaac0e0a77847931cefbe9a89d849ddb14afa15d3069109ac30911f04c56f3338
0a3b7ebdba3de09fab5bcf53dde3d37f4afa15d3069109ac30911f04c56f3338

18bb6ffaf0152bbe49cd8a3620346341





教师姓名:
48957fe0e3db86979efbd64557147e59
97784d6d895e49e6c69591adce26f069王峰4afa15d3069109ac30911f04c56f3338
0a3b7ebdba3de09fab5bcf53dde3d37f4afa15d3069109ac30911f04c56f3338

18bb6ffaf0152bbe49cd8a3620346341

2cf23ec9734b04eab760de7a9c329522

94b3e26ee717c64999d7867364b1b4a3
e8dc54b467b71980b0818a1e6bf27aae907fae80ddef53131f3292ee4f81644bd1c6776b927dc33c5d9114750b58633894b3e26ee717c64999d7867364b1b4a3
16b28748ea4df4d9c2150843fecfba68
7c74dae8fb787f9a71c709138bd8f2aa907fae80ddef53131f3292ee4f81644bd1c6776b927dc33c5d9114750b58633894b3e26ee717c64999d7867364b1b4a3
16b28748ea4df4d9c2150843fecfba68
7f1cb7d06ff35d08babbeefc58e37e4b
e72eab18e9f77ecb36f5907017b2d9e8
404dee84d1b376ad918b6bcdde566980
e388a4556c0f65e1904146cc1a846bee
94b3e26ee717c64999d7867364b1b4a3
16b28748ea4df4d9c2150843fecfba68
1d3cb0516243d16c461d661cec9e90b5
deb9743a1dda5b69a1ef24bbfc365042
92c58038775cf1060d5ea33a7a400376
a34de1251f0d9fe1e645927f19a896e8
a4b156602c47aaf400e2a27d4b1ae8c5時間b90dd5946f0946207856a8a37f441edfe3076c45f5d0a1d3325b895a78693538星期一b90dd5946f0946207856a8a37f441edfe3076c45f5d0a1d3325b895a78693538星期二4f8426b303fd482c2b5cad5323c6ce0de3076c45f5d0a1d3325b895a78693538星期三b90dd5946f0946207856a8a37f441edfe3076c45f5d0a1d3325b895a78693538星期四b90dd5946f0946207856a8a37f441edfe3076c45f5d0a1d3325b895a78693538星期五b90dd5946f0946207856a8a37f441edfe3076c45f5d0a1d3325b895a78693538星期六b90dd5946f0946207856a8a37f441edf5684456340a7231254ed8437da1dbf5b星期b90dd5946f0946207856a8a37f441edf
fd273fcf5bcad3dfdad3c41bd81ad3e5a34de1251f0d9fe1e645927f19a896e8
dd70fc6031a78a130dfe84a09a597a52早晨b90dd5946f0946207856a8a37f441edf143807004f0b65261fbe61ff80251138 b90dd5946f0946207856a8a37f441edf143807004f0b65261fbe61ff80251138 b90dd5946f0946207856a8a37f441edf143807004f0b65261fbe61ff80251138 b90dd5946f0946207856a8a37f441edfa1e30b31609c9cd32b90b0adc1ce7b98 b90dd5946f0946207856a8a37f441edf163b44447de90a6cda2846ad9205e7e2 b90dd5946f0946207856a8a37f441edf163b44447de90a6cda2846ad9205e7e2 b90dd5946f0946207856a8a37f441edfa4775c931231153f2f386d599c997c68 b90dd5946f0946207856a8a37f441edf
fd273fcf5bcad3dfdad3c41bd81ad3e5a34de1251f0d9fe1e645927f19a896e8
fad482796b325f242d598684318ba6dd上午b90dd5946f0946207856a8a37f441edf df5fdccde0bb113adbf6d2abc9398d9e第1节b90dd5946f0946207856a8a37f441edf99355b5cd9a1c338c6d144129c21e015 b90dd5946f0946207856a8a37f441edf99355b5cd9a1c338c6d144129c21e015 4f8426b303fd482c2b5cad5323c6ce0dc40985a920eb89838ee9d51b3fa5c3da b90dd5946f0946207856a8a37f441edfc40985a920eb89838ee9d51b3fa5c3da b90dd5946f0946207856a8a37f441edfc40985a920eb89838ee9d51b3fa5c3da 69a4a538b0b8a585eeb41f2e34eabb3699355b5cd9a1c338c6d144129c21e015 b90dd5946f0946207856a8a37f441edf99355b5cd9a1c338c6d144129c21e015 b90dd5946f0946207856a8a37f441edf
fd273fcf5bcad3dfdad3c41bd81ad3e5a34de1251f0d9fe1e645927f19a896e8
b6c5a531a458a2e790c1fd6421739d1c第2节b90dd5946f0946207856a8a37f441edf99355b5cd9a1c338c6d144129c21e015 b90dd5946f0946207856a8a37f441edf99355b5cd9a1c338c6d144129c21e015 b90dd5946f0946207856a8a37f441edfa31fa9877f5924fcd3aa3e02691aaeca gt;143807004f0b65261fbe61ff80251138 b90dd5946f0946207856a8a37f441edf143807004f0b65261fbe61ff80251138 b90dd5946f0946207856a8a37f441edf c40985a920eb89838ee9d51b3fa5c3da gt;c40985a920eb89838ee9d51b3fa5c3da b90dd5946f0946207856a8a37f441edf
fd273fcf5bcad3dfdad3c41bd81ad3e5a34de1251f0d9fe1e645927f19a896e8
< ;td>第3节b90dd5946f0946207856a8a37f441edf49e891595bfa5f144ee230db491ebf0d線性代数B0c6dc11e160d3b678d68754cc175188a1-17(3,4)0c6dc11e160d3b678d68754cc175188a王黎峰0c6dc11e160d3b678d68754cc175188a电教楼2050c6dc11e160d3b678d68754cc175188a计科14(1)b90dd5946f0946207856a8a37f441edf99355b5cd9a1c338c6d144129c21e015 b90dd5946f0946207856a8a37f441edf99355b5cd9a1c338c6d144129c21e015 b90dd5946f0946207856a8a37f441edf 49e891595bfa5f144ee230db491ebf0d線性代数B0c6dc11e160d3b678d68754cc175188a1-17(3,4)0c6dc11e160d3b678d68754cc175188a王黎峰0c6dc11e160d3b678d68754cc175188a电教楼2050c6dc11e160d3b678d68754cc175188a计科14(1) b90dd5946f0946207856a8a37f441edf143807004f0b65261fbe61ff80251138 gt;143807004f0b65261fbe61ff80251138 gt;143807004f0b65261fbe61ff80251138  ;b90dd5946f0946207856a8a37f441edf
fd273fcf5bcad3dfdad3c41bd81ad3e5a34de1251f0d9fe1e645927f19a896e8
b6c5a531a458a2e790c1fd6421739d1c第4节b90dd5946f0946207856a8a37f441edf99355b5cd9a1c338c6d144129c21e015 b90dd5946f0946207856a8a37f441edf 143807004f0b65261fbe61ff80251138 gt;gt; gt;

gt;  fd273fcf5bcad3dfdad3c41bd81ad3e5a34de1251f0d9fe1e645927f19a896e8
fad482796b325f242d598684318ba6dd下午b90dd5946f0946207856a8a37f441edfb6c5a531a458a2e790c1fd6421739d1c第5节b90dd5946f0946207856a8a37f441edf99355b5cd9a1c338c6d144129c21e015 b90dd5946f0946207856a8a37f441edf99355b5cd9a1c338c6d144129c21e015  ;c40985a920eb89838ee9d51b3fa5c3da gt;c40985a920eb89838ee9d51b3fa5c3da b90dd5946f0946207856a8a37f441edfc40985a920eb89838ee9d51b3fa5c3da 90cc1e42bbf9b97c5947038eac7f874e99355b5cd9a1c338c6d144129c21e015 b90dd5946f0946207856a8a37f441edf99355b5cd9a1c338c6d144129c21e015 b90dd5946f0946207856a8a37f441edf
fd273fcf5bcad3dfdad3c41bd81ad3e5a34de1251f0d9fe1e645927f19a896e8
b6c5a531a458a2e790c1fd6421739d1c第6节b90dd5946f0946207856a8a37f441edf7929ec12c1bafa6066921420eff4814d b90dd5946f0946207856a8a37f441edf7929ec12c1bafa6066921420eff4814d b90dd5946f0946207856a8a37f441edf7929ec12c1bafa6066921420eff4814d b90dd5946f0946207856a8a37f441edf7929ec12c1bafa6066921420eff4814d b90dd5946f0946207856a8a37f441edf7929ec12c1bafa6066921420eff4814d b90dd5946f0946207856a8a37f441edf7929ec12c1bafa6066921420eff4814d b90dd5946f0946207856a8a37f441edf7929ec12c1bafa6066921420eff4814d b90dd5946f0946207856a8a37f441edf
fd273fcf5bcad3dfdad3c41bd81ad3e5a34de1251f0d9fe1e645927f19a896e8
b6c5a531a458a2e790c1fd6421739d1c第7节b90dd5946f0946207856a8a37f441edf7929ec12c1bafa6066921420eff4814d b90dd5946f0946207856a8a37f441edf7929ec12c1bafa6066921420eff4814d b90dd5946f0946207856a8a37f441edf7929ec12c1bafa6066921420eff4814d b90dd5946f0946207856a8a37f441edf7929ec12c1bafa6066921420eff4814d b90dd5946f0946207856a8a37f441edf7929ec12c1bafa6066921420eff4814d b90dd5946f0946207856a8a37f441edf7929ec12c1bafa6066921420eff4814d b90dd5946f0946207856a8a37f441edf7929ec12c1bafa6066921420eff4814d b90dd5946f0946207856a8a37f441edf
fd273fcf5bcad3dfdad3c41bd81ad3e5a34de1251f0d9fe1e645927f19a896e8
b6c5a531a458a2e790c1fd6421739d1c第8节b90dd5946f0946207856a8a37f441edf7929ec12c1bafa6066921420eff4814d b90dd5946f0946207856a8a37f441edf7929ec12c1bafa6066921420eff4814d b90dd5946f0946207856a8a37f441edf7929ec12c1bafa6066921420eff4814d b90dd5946f0946207856a8a37f441edf7929ec12c1bafa6066921420eff4814d b90dd5946f0946207856a8a37f441edf7929ec12c1bafa6066921420eff4814d b90dd5946f0946207856a8a37f441edf7929ec12c1bafa6066921420eff4814d b90dd5946f0946207856a8a37f441edf7929ec12c1bafa6066921420eff4814d b90dd5946f0946207856a8a37f441edf
fd273fcf5bcad3dfdad3c41bd81ad3e5a34de1251f0d9fe1e645927f19a896e8
a520914fc27d227038050476e39ade97晚上b90dd5946f0946207856a8a37f441edfb6c5a531a458a2e790c1fd6421739d1c第9节b90dd5946f0946207856a8a37f441edf7929ec12c1bafa6066921420eff4814d b90dd5946f0946207856a8a37f441edf7929ec12c1bafa6066921420eff4814d b90dd5946f0946207856a8a37f441edf7929ec12c1bafa6066921420eff4814d b90dd5946f0946207856a8a37f441edf7929ec12c1bafa6066921420eff4814d b90dd5946f0946207856a8a37f441edf7929ec12c1bafa6066921420eff4814d b90dd5946f0946207856a8a37f441edf7929ec12c1bafa6066921420eff4814d b90dd5946f0946207856a8a37f441edf7929ec12c1bafa6066921420eff4814d b90dd5946f0946207856a8a37f441edf
fd273fcf5bcad3dfdad3c41bd81ad3e5a34de1251f0d9fe1e645927f19a896e8
b6c5a531a458a2e790c1fd6421739d1c第10节b90dd5946f0946207856a8a37f441edf7929ec12c1bafa6066921420eff4814d b90dd5946f0946207856a8a37f441edf7929ec12c1bafa6066921420eff4814d b90dd5946f0946207856a8a37f441edf7929ec12c1bafa6066921420eff4814d b90dd5946f0946207856a8a37f441edf7929ec12c1bafa6066921420eff4814d b90dd5946f0946207856a8a37f441edf7929ec12c1bafa6066921420eff4814d b90dd5946f0946207856a8a37f441edf7929ec12c1bafa6066921420eff4814d b90dd5946f0946207856a8a37f441edf7929ec12c1bafa6066921420eff4814d b90dd5946f0946207856a8a37f441edf
fd273fcf5bcad3dfdad3c41bd81ad3e5
f16b1740fad44fb09bfe928bcc527e08
c474806c1b49f890ebb5bd06e2d26ef3

9682fe421761c3eef67c85b39b7aa521
f70d0ebff76a19226909a4a79919b5e8
aa6150982426b9c9441a298f2619fefa实践课(或无上课时间)信息:02316988d1129bf85d55319dd82c6742
028c8978a801aab69fbfabf6c40af099
f70d0ebff76a19226909a4a79919b5e8
a3da524fa351fac538742266a252946642fc497eb47a2d1e4840495e85698962
854b99c876b544460731c0b30e7aadeb
b6c5a531a458a2e790c1fd6421739d1c课程名称b90dd5946f0946207856a8a37f441edfb6c5a531a458a2e790c1fd6421739d1c教师b90dd5946f0946207856a8a37f441edfb6c5a531a458a2e790c1fd6421739d1c学分b90dd5946f0946207856a8a37f441edfb6c5a531a458a2e790c1fd6421739d1c起止周b90dd5946f0946207856a8a37f441edfb6c5a531a458a2e790c1fd6421739d1c上课时间b90dd5946f0946207856a8a37f441edfb6c5a531a458a2e790c1fd6421739d1c上课地点b90dd5946f0946207856a8a37f441edfb6c5a531a458a2e790c1fd6421739d1c教学班组成b90dd5946f0946207856a8a37f441edf
fd273fcf5bcad3dfdad3c41bd81ad3e5
f16b1740fad44fb09bfe928bcc527e0802316988d1129bf85d55319dd82c6742
028c8978a801aab69fbfabf6c40af099
4dc0f4909dd0df5602d52ec2d80eb175
30cae5dd68ee562cdc1c82c29e307610调、停(补)课信息:16b28748ea4df4d9c2150843fecfba68
372e6b49e0b125a2e928acb29ffd1e24
d3198c2343929931f84a75f246f51454
b6c5a531a458a2e790c1fd6421739d1c番号b90dd5946f0946207856a8a37f441edfb6c5a531a458a2e790c1fd6421739d1cコース名b90dd5946f0946207856a8a37f441edfb6c5a531a458a2e790c1fd6421739d1c元の授業時間と場所b90dd5946f0946207856a8a37f441edfb6c5a531a458a2e790c1fd6421739d1c現在の授業時間と場所bdfb2a3117151b089cbb18cdd102d815
a25cdad71f9d3aefe7f581b3c2adeb91
9abf1c2be3fd4703586f386db42af42e54bdf357c58b8a65c66d7c19c8e4d114
4809e6dffab321bb070f5105fcca6c3054bdf357c58b8a65c66d7c19c8e4d114
d1c6776b927dc33c5d9114750b586338
16b28748ea4df4d9c2150843fecfba68
16b28748ea4df4d9c2150843fecfba68
16b28748ea4df4d9c2150843fecfba68
e083986a812e016ef20466f844ca7465
f2475bc0d02a524246eacdb398ec424e
6eac519e8537e4205ddd37e30a7b548a


-----ソリューションのアイデア-------------- ----- --
<br />include 'simple_html_dom.php';//这个你可以在网上下载一个<br /><br />$dom=new simple_html_dom();<br />//要将内容转为 utf-8 才能处理<br />$dom->load($content);<br />$names=$dom->find('select[id=js]');<br />$res=array();<br />$res['name']=$names[0]->find('option[selected=selected]')[0]->text();<br />$tabletr=$dom->find('table[id=Table6] tr');<br />foreach($tabletr as $k=>$tr){<br />	foreach($tr->find('td') as $k1=>$td){<br />		if($k1!==0){<br />			$info[$k][$k1]=$td->text();<br />		}<br />	}<br />}<br />//优化数据<br />foreach($info as $k=>$v){<br />	if($k==1){<br />		unset($info[1]);<br />	}<br />	if(count($v)==8){<br />		unset($v[1]);<br />	}<br />	$info[$k]=array_values($v);<br />}<br />$week=$info[0];<br />unset($info[0]);<br />//组织数据<br />foreach($info as $v){<br />	foreach($v as $k=>$v){<br />		$tmp[$week[$k]][]=$v;<br />	}<br />}<br />$res['info']=$tmp;<br /><br />echo "<pre class="brush:php;toolbar:false">";<br />print_r($res);<br />echo "
";
/*
Array
(
[name] => 王峰
[info] => Array
(
[星期一] => Array
(
[0] =>
[1] =>
[2] => 线性代数B
1-17(3,4)
王黎峰
电教楼205
计科14(1)
[3] =>
[4] =>
[5] =>
[6] =>
[7] =>
[8] =>
[9] =>
[10] =>
)

[星期二] => Array
(
[0] =>
[1] =>
[2] =>
[3] =>
[4] =>
[5] =>
[6] =>
[7] =>
[8] =>
[9] =>
[10] =>
)

[星期三] => Array
(
[0] =>
[1] =>
[2] =>
[3] =>
[4] =>
[5] =>
[6] =>
[7] =>
[8] =>
[9] =>
[10] =>
)

[星期四] => Array
(
[0] =>
[1] =>
[2] => 线性代数B
1-17(3,4)
王黎峰
电教楼205
计科14(1)
[3] =>
[4] =>
[5] =>
[6] =>
[7] =>
[8] =>
[9] =>
[10] =>
)

[星期五] => Array
(
[0] =>
[1] =>
[2] =>
[3] =>
[4] =>
[5] =>
[6] =>
[7] =>
[8] =>
[9] =>
[10] =>
)

[星期六] => Array
(
[0] =>
[1] =>
[2] =>
[3] =>
[4] =>
[5] =>
[6] =>
[7] =>
[8] =>
[9] =>
)

[星期日] => Array
(
[0] =>
[1] =>
[2] =>
[3] =>
[4] =>
[5] =>
[6] =>
[7] =>
[8] =>
[9] =>
)

)

)
*/
//根据你自己的需求来处理课程信息
$txt = <<线性代数B
1-17(3,4)
王黎峰
电教楼205
计科14(1)
EOF;
$arr=explode(PHP_EOL,$txt);
echo "
";<br />print_r($arr);<br />echo "
";
声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。