このような文字列を解析する方法
次はファイル内の文字列の行です:
[2007-08-01 00:00:00] 218.200.244.69 - - "GET /cmcc/ani/klfyt_detail_at.jsp ?nofee= 1&type=video&id=10477&sid=GUIBWqU0F57trFtS&dirid=0428100540&p=1&session=&MISC_ID=999&MISC_SessionID=999-df1b2815!1434701435!1257454712!1185897536315 &MISC _ServiceID=30070881&MISC_AccessMode=2&MISC_MID=00110080331963 HTTP/1.0 " 200 8376 "- " "TSD-TP005 " ワップ.chinam.com 1
次のデータを取得したいのですが、解析方法を教えてください:
[2007-08-01 00:00:00]
218.200 .244.69
-
-
"GET /cmcc/ani/klfyt_detail_at.jsp?nofee=1&type=video&id=10477&sid=GUIBWqU0F57trFtS&dirid=0428100540&p=1&session=&MISC_ID=999&MISC_SessionID= 999-df1b28 15!1434701435!1257454712 !1185897536315&MISC_ServiceID=30070881&MISC_AccessMode=2&MISC_MID=00110080331963 HTTP/1.0 "
200
8376
-
"TSD-TP005 "
.com
1
----- -解決策--------------------
$html = " [2007-08-01 00 :00:00] 218.200.244.69 - - "
GET /cmcc/ani/klfyt_detail_at.jsp?nofee=1&type=video&id=10477&sid=GUIBWqU0F57trFtS
&dirid=0428100540&p= 1&セッション=&MISC_ID =99 9&MISC_SessionID=999-df1b2815! 1434701435!
1257454712!1185897536315&MISC_ServiceID=30070881&MISC_AccessMode=2&MISC_MID=00110080331963
HTTP/1.0 " 200 8376 "- "TSD-TP005 " ap.chinam.com 1 ";
$match = '/ [([^]]*)]([^ "]*) "([^ "]*) "/is ';
$re = preg_match_all (
$match ,
$html,
$out);
print_r( $out );
?>
------解決策---------
参照: ===== = ========================= $str = '[2007-08-01 00:00:00] 218.200.244.69 - - " GET /cmcc/ani/klfyt_detail_at.jsp?nofee=1&type=video&id=10477&sid=GUIBWqU0F57trFtS&dirid=0428100540&p=1&session=&MISC_ID=999&MISC_SessionID=999-df1b2815!1434701435!1 54712!1185897536315&MISC_ServiceID=30070881&MISC_AccessMode=2&MISC_MID=00110080331963 HTTP/1.0 " 200 8376 "- " "TSD-TP005 " wap.chinam.com 1 ';
$arr = preg_match_all( '/( "(.[^ "]*?) ")|([(.[^] ]*?)])|(s(.[^s+]*?)s)|(.[^s]*)/ ',$str,$m);
print_r($m[0]) ;
------解決策------
$s = <
0881&MISC_AccessMode=2&MISC_MID=00110080331963 HTTP/1.0 " 0 8376 "-" "TSD-TP005 " wap.chinam.com 1
H;
$r = preg_split( "/s+/ ",$s);
print_r($r);