ホームページ >バックエンド開発 >PHPチュートリアル >もう 1 つの PHP 正規表現の質問です。テキストを 2 次元配列に一致させるというスコアは素晴らしいです。
查询结果如下: 该交通违法有记录! 信息来源: 非现场记录 文书号/决定书号/文书编号: 未裁决,无 车牌号码: 粤K32889 车主名称: 号牌种类: 违法时间: 2011-02-08 15:21:52.0 违法地点: 省道高铜线台山市斗山镇路段 采集机关: 台山市公安局交通警察大队斗山中队 所在地市: 违法行为名称: 机动车行驶超过规定时速50%以下的 处理地点: 台山市台城缠溪松山咀 处理地点联系电话: 0750-5520011 信息来源: 非现场记录 文书号/决定书号/文书编号: 未裁决,无 车牌号码: 粤K32889 车主名称: 号牌种类: 违法时间: 2010-10-25 07:12:57.0 违法地点: 东莞市长安镇莱茵阁路口(固定电子警察) 采集机关: 东莞市公安局交通警察支队长安大队 所在地市: 违法行为名称: 机动车通过有灯控路口时,不按所需行进方向驶入导向车道的 处理地点: 东莞市长安镇大板地工业大道1号 处理地点联系电话: 0769-81661611 信息来源: 非现场记录 文书号/决定书号/文书编号: 未裁决,无 车牌号码: 粤K32889 车主名称: 号牌种类: 违法时间: 2010-12-29 20:34:39.0 违法地点: 振安夏边路口(东-西) 采集机关: 东莞市公安局交通警察支队长安大队 所在地市: 违法行为名称: 机动车通过有灯控路口时,不按所需行进方向驶入导向车道的 处理地点: 东莞市长安镇大板地工业大道1号 处理地点联系电话: 0769-81661611 设为首页 | 加入收藏 | 联系方法 | 网站地图 | 友情链接 | 版权声明 版权所有 2006 广东省公安厅交通管理局政务服务网 ePRO易宝电脑系统(广州)有限公司提供技术支持 未经许可不得转载及建立镜像 否则追究法律责任
$array[0][0]=非现场记录$array[0][1]=2011-02-08 15:21:52.0$array[0][2]=省道高铜线台山市斗山镇路段$array[0][3]=台山市公安局交通警察大队斗山中队$array[0][4]=机动车行驶超过规定时速50%以下的$array[0][5]=台山市台城缠溪松山咀$array[1][0]=非现场记录$array[1][1]=2010-10-25 07:12:57.0..............................................................$array[2][5]=东莞市长安镇大板地工业大道1号
何気なく書いたものですが、テスト結果は暫定的なものです。まだ不足しているだけです。導入として使用してください
([\S|/]+:\s)([\S]+)
$str = <<<str查询结果如下: 该交通违法有记录! 信息来源: 非现场记录 文书号/决定书号/文书编号: 未裁决,无 车牌号码: 粤K32889 车主名称: 号牌种类: 违法时间: 2011-02-08 15:21:52.0 违法地点: 省道高铜线台山市斗山镇路段 采集机关: 台山市公安局交通警察大队斗山中队 所在地市: 违法行为名称: 机动车行驶超过规定时速50%以下的 处理地点: 台山市台城缠溪松山咀 处理地点联系电话: 0750-5520011 信息来源: 非现场记录 文书号/决定书号/文书编号: 未裁决,无 车牌号码: 粤K32889 车主名称: 号牌种类: 违法时间: 2010-10-25 07:12:57.0 违法地点: 东莞市长安镇莱茵阁路口(固定电子警察) 采集机关: 东莞市公安局交通警察支队长安大队 所在地市: 违法行为名称: 机动车通过有灯控路口时,不按所需行进方向驶入导向车道的 处理地点: 东莞市长安镇大板地工业大道1号 处理地点联系电话: 0769-81661611 信息来源: 非现场记录 文书号/决定书号/文书编号: 未裁决,无 车牌号码: 粤K32889 车主名称: 号牌种类: 违法时间: 2010-12-29 20:34:39.0 违法地点: 振安夏边路口(东-西) 采集机关: 东莞市公安局交通警察支队长安大队 所在地市: 违法行为名称: 机动车通过有灯控路口时,不按所需行进方向驶入导向车道的 处理地点: 东莞市长安镇大板地工业大道1号 处理地点联系电话: 0769-81661611 设为首页 | 加入收藏 | 联系方法 | 网站地图 | 友情链接 | 版权声明 版权所有 2006 广东省公安厅交通管理局政务服务网 ePRO易宝电脑系统(广州)有限公司提供技术支持 未经许可不得转载及建立镜像 否则追究法律责任str;preg_match_all('/ 信息来源 :\s(.+)\s.+ #来源# :\s([\d \-\.:]+\.0).+ #时间# :\s(.+)\s.+ #地点# :\s(.+)\s.+ #采集机关# :.+: \s(.+)\s.+ #违法行为名称# \s(.+)\s.+ #处理地点# \d{4}\-\d{5,} /Usx', $str, $matches);$res = array();for ($i = 0; $i < count($matches[1]); $i++){ for ($j = 1; $j <= 6; $j++){ $res[$i][] = $matches[$j][$i]; }}echo '<pre class="brush:php;toolbar:false">';print_r($res);echo '';/** *Array( [0] => Array ( [0] => 非现场记录 [1] => 2011-02-08 15:21:52.0 [2] => 省道高铜线台山市斗山镇路段 [3] => 台山市公安局交通警察大队斗山中队 [4] => 机动车行驶超过规定时速50%以下的 [5] => 台山市台城缠溪松山咀 ) [1] => Array ( [0] => 非现场记录 [1] => 2010-10-25 07:12:57.0 [2] => 东莞市长安镇莱茵阁路口(固定电子警察) [3] => 东莞市公安局交通警察支队长安大队 [4] => 机动车通过有灯控路口时,不按所需行进方向驶入导向车道的 [5] => 东莞市长安镇大板地工业大道1号 ) [2] => Array ( [0] => 非现场记录 [1] => 2010-12-29 20:34:39.0 [2] => 振安夏边路口(东-西) [3] => 东莞市公安局交通警察支队长安大队 [4] => 机动车通过有灯控路口时,不按所需行进方向驶入导向车道的 [5] => 东莞市长安镇大板地工业大道1号 )) **/ は十分に退屈なので、文字列を直接インターセプトする方が良いです
PHP コード
$str = <<
ZT_King は規則的なルールの達人であり、教えられ、学んできました
素晴らしい人です
PHP コード
$str = <<
ZT_King どうやってそれを傍受するのですか? 1 日 Google で検索しましたが見つかりませんでした。いつものように頭痛がします。
$str = <<<str......str;
私のソース コードは変数 $b に保存されています。 $str=$b; これは不可能です。どうすればよいでしょうか?
<<
NAME
$b は複数行のコンテンツです。どのように変更すればよいでしょうか?ありがとうございます
<<
NAME
$str=$b を実行してもまだ使用できない場合は、$b コンテンツのエンコーディングの問題です。 $str = iconv('gbk','utf8',$b); を試してください。
はい、すべてのデータが一致しています。確認したところ、ループ内にエラーがあったため、次のデータが正常ではありませんでした。エンコーディングをもっと確認する必要があります
for ($i = 0; $i < count($matches[0]); $i++){
$str = <<<str=!信息来源: 非现场记录文书号/决定书号/文书编号: 未裁决,无车牌号码: 粤K32889车主名称: 号牌种类: 违法时间: 2011-02-08 15:21:52.0违法地点: 省道高铜线台山市斗山镇路段采集机关: 台山市公安局交通警察大队斗山中队所在地市: 违法行为名称: 机动车行驶超过规定时速50%以下的处理地点: 台山市台城缠溪松山咀处理地点联系电话: 0750-5520011信息来源: 非现场记录文书号/决定书号/文书编号: 未裁决,无车牌号码: 粤K32889车主名称: 号牌种类: 违法时间: 2010-10-25 07:12:57.0违法地点: 东莞市长安镇莱茵阁路口(固定电子警察)采集机关: 东莞市公安局交通警察支队长安大队所在地市: 违法行为名称: 机动车通过有灯控路口时,不按所需行进方向驶入导向车道的处理地点: 东莞市长安镇大板地工业大道1号处理地点联系电话: 0769-81661611信息来源: 非现场记录文书号/决定书号/文书编号: 未裁决,无车牌号码: 粤K32889车主名称: 号牌种类: 违法时间: 2010-12-29 20:34:39.0违法地点: 振安夏边路口(东-西)采集机关: 东莞市公安局交通警察支队长安大队所在地市: 违法行为名称: 机动车通过有灯控路口时,不按所需行进方向驶入导向车道的处理地点: 东莞市长安镇大板地工业大道1号处理地点联系电话: 0769-81661611 设为首页 | 加入收藏 | 联系方法 | 网站地图 | 友情链接 | 版权声明版权所有 2006 广东省公安厅交通管理局政务服务网ePRO易宝电脑系统(广州)有限公司提供技术支持未经许可不得转载及建立镜像 否则追究法律责任str;
この方法ではマッチングは成功しません
str_replace();
違います、
マッチングアルゴリズムを直接変更すれば良いのではないでしょうか
……
フォームコンテンツが
preg_match_all('/ 信息来源 :\s(.+)\s.+ #来源# :\s([\d \-\.:]+\.0).+ #时间# :\s(.+)\s.+ #地点# :\s(.+)\s.+ #采集机关# :.+: \s(.+)\s.+ #违法行为名称# \s(.+)\s.+ #处理地点# \d{4}\-\d{5,} /Usx', $str, $matches);であると仮定します
確認コードは
$str = <<';/** * Array( [0] => Array ( [0] => 非现场记录 [1] => 2011-02-08 15:21:52.0 [2] => 省道高铜线台山市斗山镇路段 [3] => 台山市公安局交通警察大队斗山中队 [4] => 机动车行驶超过规定时速50%以下的 [5] => 台山市台城缠溪松山咀 ) [1] => Array ( [0] => 非现场记录 [1] => 2010-10-25 07:12:57.0 [2] => 东莞市长安镇莱茵阁路口(固定电子警察) [3] => 东莞市公安局交通警察支队长安大队 [4] => 机动车通过有灯控路口时,不按所需行进方向驶入导向车道的 [5] => 东莞市长安镇大板地工业大道1号 ) [2] => Array ( [0] => 非现场记录 [1] => 2010-12-29 20:34:39.0 [2] => 振安夏边路口(东-西) [3] => 东莞市公安局交通警察支队长安大队 [4] => 机动车通过有灯控路口时,不按所需行进方向驶入导向车道的 [5] => 东莞市长安镇大板地工业大道1号 )) * */';print_r($res);echo '
フォームの送信に snoopy を使用します
<form method="post" action="http://www.gdgajj.com/cx/wzss/wzss.do" > 名字: <input name='jc' type='text' value='粤' style='width:20'> 验证码: <input type='text' name='randcode2' size='5' value=''> <img src="http://www.gdgajj.com/cx/servlet/ImageServlet" > <input name='image2' type='submit'></form>
$img="a.jpg" //当前目录下的验证码图片名字include ('Valite.php');$valite = new Valite();$valite->setImage($img);$valite->getHec();$ert = $valite->run();//$ert就是识别出来的数字を使用して確認コード
を取得するにはどうすればよいですか? それでも、サーバー上のセッションを確実にするには何を使用すればよいですか?
送信したコードをリンクする方法
フォーム送信をシミュレートするモジュールを組み合わせる方法
起きてください。
このような文字列を求めてください $str
$str='[0,"通信情報工学部","","","","",3,"","","", -1 ,2,"通信工学","","","",3,"","pubStuKebiao.php?zyh=0101","frameList",2,
"電子情報工学","", "" ,"",3,"","pubStuKebiao.php?zyh=0102","frameList",2,"電子情報科学技術","","","",3,""," pubStuKebiao.php? zyh=0103","frameList",2,"情報工学","","","",3,"","pubStuKebiao.php?zyh=0104","frameList",2 ," ラジオおよびテレビ工学","","","",3,"","pubS
tuKebiao.php?zyh=0105","frameList",2,"コミュニケーションと情報",""," ", "",3,"","pubStuKebiao.php?zyh=0114","frameList",2,"通信情報実験
授業","","","",3,""," pubStuKebiao .php?zyh=0118","frameList",2,"コミュニケーション学部優秀クラス","","","",3,"","pubStuKebiao.php?zyh=0190"," FrameList"
, 2,"通信学部 IT エリートクラス","","","",3,"","pubStuKebiao.php?zyh=0191","frameList",2,"通信工学国際実験授業","" ,"","",3,"","pubStuKebiao.php
?zyh=0192","frameList",2,"電子情報工学(通信技術方面)","", "","",3 ,"","pubStuKebiao.php?zyh=2003","frameList",2,"電子情報工学(通信技術)","","","",3,"" ,"pubStuKebiao.php ?zyh=5101","frameList",2,"電子情報工学(応用電子技術)","","","",3,"","pubStuKebiao.php?zyh=5102 ","
frameList ",2,"電子情報工学(実験授業)","","","",3,"","pubStuKebiao.php?zyh=5109","frameList",1,0 ,"光電子工学専門学校","","","","",3,"","",""
,-1,2,"光情報科学技術","","", "",3 ,"","pubStuKebiao.php?zyh=0201","frameList",2,"マイクロエレクトロニクス","","","",3,"","pubStuKebiao.php?zyh=0202 "
,"frameList",2,"電子科学技術","","","",3,"","pubStuKebiao.php?zyh=0203","frameList",2,"電子工学" , "","","",3,"","pubStuKebiao.php
?zyh=0211","frameList",2,"マイクロエレクトロニクス工学実験教室","","","",3, "","pubStuKebiao.php?zyh=0219","frameList",1,0,"経済経営学部","","","","",3,
"","", "" ,-1,2,"情報管理と情報システム","","","",3,"","pubStuKebiao.php?zyh=0301","frameList",2,"会計", " ","","",3,"","pubStuKebiao.php
?zyh=0302","frameList",2,"経済学","","","",3,""," pubStuKebiao.php?zyh=0303","frameList",2,"マーケティング","","","",3,"","pubStuKebiao.ph
p?zyh=0304","frameList", 2 ,"経営管理","","","",3,"","pubStuKebiao.php?zyh=0305","frameList",2,"電子商取引","","","" ,3,"","pubStuKebiao
.php?zyh=0306","frameList",2,"プロジェクト管理","","","",3,"","pubStuKebiao.php?zyh=0308 ","frameList",2,"情報管理","","","",3,"","pubStuK
ebiao.php?zyh=0311","frameList",2,"経営管理 ", "","","",3,"","pubStuKebiao.php?zyh=0312","frameList",2,"国際会計人材育成実験教室","
","","",3,"","pubStuKebiao.php?zyh=0318","frameList",2,"経営学実験授業","","","",3,"" , "pubStuKebiao.php?zyh=0390","frameList",2,"
経済実験授業","","","",3,"","pubStuKebiao.php?zyh=0391","frameList" ,2,"マーケティング (企業のマーケティングと経営の方向性)","","","",3,"","pubStuKebiao.
php?zyh=2004","frameList",2,"情報管理と情報システム","","","",3,"","pubStuKebiao.php?zyh=2009","frameList",1,0,"コンピュータ科学技術学部","
", "" ,"","",3,"","","",-1,2,"コンピュータ科学技術","","","",3,"","pubStuKebiao.php ?zyh =0401","frameList",2,"地理情報システム","","","",3,"",
"pubStuKebiao.php?zyh=0402","frameList",2," ネットワークエンジニアリング","","","",3,"","pubStuKebiao.php?zyh=0403","frameList",2,"情報セキュリティ","","","",3,
" ","pubStuKebiao.php?zyh=0404","frameList",2,"知的科学技術","","","",3,"","pubStuKebiao.php?zyh=0405" ," FrameList",2,"コンピューターと知能
科学","","","",3,"","pubStuKebiao.php?zyh=0412","frameList",2,"コンピューターと知能 科学実験教室","","","",3,"","pubStuKebiao.php?zyh=0418
","frameList",2,"コンピューターサイエンス学部の優秀クラス","","", " ",3,"","pubStuKebiao.php?zyh=0491","frameList",2,"コンピューター科学技術","","","",3,"","pubStu
ケビアオ。 ?zyh=2001","frameList",2,"コンピュータ科学技術 (コンピュータアプリケーション)","","","",3,"","pubStuKebiao.php?zyh=5301","frameList " ,2,"コンピューター サイエンス
学習とテクノロジー (ネットワーク テクノロジー)","","","",3,"","pubStuKebiao.php?zyh=5302","frameList",2,"コンピューター サイエンスと技術(情報セキュリティ)","","","",3,"","pubStuKebi
ao.php?zyh=5303","frameList",2,"コンピュータ科学技術(実験授業) ", "","","",3,"","pubStuKebiao.php?zyh=5309","frameList",1,0,"外国語学部"
,"","",""," ",3,"","","",-1,2,"英語","","","",3,"","pubStuKebiao.php?zyh=0501","frameList", 2,"英語(ビジネス)","","","",3,"","pubStuKebia
.php?zyh=5401","frameList",1,0,"バイオインフォマティクス学部","" ,"","","",3,"","","",-1,2,"生体医工学","","","",3,"","pubStuKebiao.php ? zyh=0601","
FrameList",2,"バイオテクノロジー","","","",3,"","pubStuKebiao.php?zyh=0602","frameList",2,"中薬局" ,"","","",3,"","pubStuKebiao.php?zyh=0603","
フレームリスト",2,"製薬工学","","","",3, "" ,"pubStuKebiao.php?zyh=0604","frameList",2,"バイオインフォマティクス","","","",3,"","pubStuKebiao.php?zyh=060
5" ,"frameList" ,2,"バイオテクノロジーと医薬品","","","",3,"","pubStuKebiao.php?zyh=0611","frameList",2,"バイオテクノロジー (生物学情報学)","", "","",3,
"","pubStuKebiao.php?zyh=0615","frameList",2,"生物学と薬学実験教室",""," ","",3,"", "pubStuKebiao.php?zyh=0690","frameList",1,0,"ロースクール",
"","","","",3,"" ,"","",-1, 2]';このような 2 次元配列を実現するための通常の正規表現の書き方