[英]Parse HTML or Plain Text File and return the text delimited by a string
I need help in parsing a text file. 我在解析文本文件时需要帮助。 This text file has a few html tags in it.
该文本文件中包含一些html标记。 What I am looking for is a Solution (Either in PHP or JS or both) which will strip all these, and store the output into separate variables.
我正在寻找的是一种解决方案(无论是PHP还是JS,或两者兼有),它将剥离所有这些内容,并将输出存储到单独的变量中。
Integration/QA
<http://shopfloor/sfweb/secure/CancelOrders>
Development
<http://shopfloor/sfweb/secure/CancelOrders>
------------------------------------------------------------------------
*HEADER INFO*
*View Object:* 6541997 *BPO:* 0020064484 *Ack Date:* 2012-05-25
*Operation(s):* PS_Queue, PS_BoxAll, JPN_End
------------------------------------------------------------------------
*EXTERNAL ORDER NUMBER REFERENCE*
*SAP Sales Order Number* *Customer P.O. Number* *Legacy Order Number*
0310407774 89FC37763001
------------------------------------------------------------------------
*PRODUCTS FOR THIS WORK OBJECT/OPERATION(S)*
*PL* *Product #* *Qty* *Options* *Serial #*
LN AE241A 1
------------------------------------------------------------------------
*Station Info*
*Start Station:* JPN_End *Location:* Done *Station:*
*Birth Date/Time:* 2012-05-22 08:26:17 SGT *Power Cord:* *Voltage:*
------------------------------------------------------------------------
*MATERIAL LIST FOR THIS WORK OBJECT/OPERATION(S)*
*Part Number* *Qty* *Description* *BB Type* *Material
Location* *Serial Number*
AE241-90001 1 XP Remote Support Service Leaflet BOM PACK
Privacy Statement
I basically Want to strip a few text from this code into php variables, so it will return: 我基本上想将这段代码中的一些文本剥离到php变量中,所以它将返回:
$viewobject = "6541997"
$BPO = "0020064484"
$ackdate = "2012-05-25"
$operations = "PS_Queue, PS_BoxAll, JPN_End"
$sapSO = "0310407774"
$legacyON = "89FC37763001"
$pl = "LN"
$product = "AE241A"
$qty = 1;
$startstn = "JPN_end"
$location = "Done"
$bdate = "PS_Queue, PS_BoxAll, JPN_End"
$pn = "AE241-90001"
$qty = 1;
$description =" XP Remote Support Service Leaflet";
and the like. 等等。 Is this possible?
这可能吗?
Use regular expression . 使用正则表达式 。
preg_match_all('/\*(view object|bpo|ack date):\*\s+([0-9\-]+)/i', $text, $m);
// $m contains matches, try to print_r($m)
$viewobject = $m[2][0]; // 6541997
$bpo = $m[2][1]; // 0020064484
$ackdate = $m[2][2]; // 2012-05-25
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.