2010-07-15 62 views
0

我怎樣才能在下面的字符串匹配「Because it already exists」用正則表達式:如何匹配任何其他文本之前一些文字

<faultstring>Error has occured! Reason why: Because it already exists. request id: 443p3-34356a</faultstring> 

這expressio失敗:

(.+)+Because it already exists(.+)+ 

我需要匹配<faultstring></faultstring>爲所以我需要匹配Because it already exists裏面的真空開關標籤

說明:

這是一個多行字符串,我只是打印出這一個是很重要的。

+0

此外,您還可以嘗試http://www.rexv.org/輕鬆地評估對源文本的正則表達式。 – 2010-07-15 09:51:09

回答

1

更簡單地說:

/Because it already exists/ 
+1

你是什麼意思的「不工作」? – Toto 2010-07-15 11:19:15

4

我不認爲你想要那些外部加號。

(.+)Because it already exists(.+) 
0

這將做什麼你問:

(?<=.+)Because it already exists(?=.+) 

但是它看起來像你正在做的事情不尋常,有可能是一個更好的方式來做到這一點。

你想做什麼?

相關問題