可能重複:
How to do unfolding RFC 822
Parsing e-mail-like headers (similar to RFC822)正則表達式 「固定」 的電子郵件標題,使他們一行
我有一個類似於E-一些輸入數據電子郵件數據,長行被包裝到下一行。例如:
robot-useragent: ABCdatos BotLink/1.0.2 (test links)
robot-language: basic
robot-description: This robot is used to verify availability of the ABCdatos
directory entries (http://www.abcdatos.com), checking
HTTP HEAD. Robot runs twice a week. Under HTTP 5xx
error responses or unable to connect, it repeats
verification some hours later, verifiying if that was a
temporary situation.
的robot-description
字段是「太長」一行,並且纏繞到下一個。在分析這些數據的幫助,我想拿出可與preg_replace()
可以使用正則表達式符合下列條件取代:
- 新行字符跟空格
- 不更換新線的字符,隨後附加的新行字符
輸出示例:
robot-description: This robot is used to verify availability of the ABCdatos directory entries (http://www.abcdatos.com), checking HTTP HEAD. Robot runs twice a week. Under HTTP 5xx error responses or unable to connect, it repeats verification some hours later, verifiying if that was a temporary situation.
我是RegEx的新手。我怎樣才能建立這樣的表達?如果您選擇回答,請在表達式中包含組件的簡要說明。我真的很想學習如何做到這些。
我已經開始了:\n([^\S])*
它很接近。 http://codepad.org/iMObpgFX
@MarcB,這不重複。在我的另一個問題中,我正在詢問如何以類似於內置IMAP函數的方式處理標題。在這個問題中,我特別要求關於RegEx重新加入系列。在我看來,這些完全是分開的問題。雖然他們與我有相同的目標,但我想知道兩者的解決方案。如果您不同意,請告訴我。 – Brad