前提
webブラウザ(chrome,Edge)にてログの必要な情報のみを整形して表示させたいのですが、
仕切り文字である「スペース」が抽出したい文字列の中にも含まれており、
split関数にて区切ると繋げて表示したい個所も区切られてしまい困っています。
以下にあるログのうち 「msg="~~"」のみ文字列中に「スペース」が挿入されています。
他のシステムアラームのログでも「スペース」が挿入されておりここだけ例外的に扱いたいです。
正規表現について学んだり他の手段がないか調べたりしたのですが、1週間程進捗がないため質問させていただきました。
date=2018-12-27 time=11:28:07 logid="0419016384" type="utm" subtype="ips" eventtype="signature" level="alert" vd="vdom1" eventtime=1545938887 severity="info" srcip=172.16.200.55 srccountry="Reserved" dstip=10.1.100.11 srcintf="port11" srcintfrole="undefined" dstintf="port12" dstintfrole="undefined" sessionid=901 action="reset" proto=6 service="HTTP" policyid=1 attack="Eicar.Virus.Test.File" srcport=80 dstport=44362 hostname="172.16.200.55" url="/virus/eicar.com" direction="incoming" attackid=29844 profile="test-ips" ref="http://www.fortinet.com/ids/VID29844" user="bob" incidentserialno=877326946 msg="file_transfer: Eicar.Virus.Test.File," msg=" Fortigate scheduled update failed"
実現したいこと
ここに実現したいことを箇条書きで書いてください。
- msg="~~"がつながった状態で配列に入れたい
var log = 'date=2018-12-27 time=11:28:07 ~~ msg="file_transfer: Eicar.Virus.Test.File," '; var log_after = log.split(/ /g); console.log(log_after) //['date=2018-12-27', 'time=11:28:07', ~~, 'msg="file_transfer:', 'Eicar.Virus.Test.File"'] →理想はこれで表示したい//['date=2018-12-27', 'time=11:28:07', ~~, 'msg="file_transfer: Eicar.Virus.Test.File"']
回答2件
あなたの回答
tips
プレビュー