How to match some text preceded by any other text
How can I match "Because it already exists
" with regex in string below :
<faultstring>Error has occured! Reason why: Because it already exists. request id: 443p3-34356a</faultstring>
This expressio fails :
(.+)+Because it already exists(.+)+
I need to match <faultstring></faultstring>
as well, so I need to match Because it already exists
inside faulstring opening and closing tags
note:
T开发者_如何学Pythonhis is a multiline string, I just printed out this one it is important.
I don't think you want those outer pluses.
(.+)Because it already exists(.+)
More simply :
/Because it already exists/
Using this online regular expression tester, I found that Borealid reply totally fulfills your need.
This will do what you ask:
(?<=.+)Because it already exists(?=.+)
However it looks like you are doing something unusual and there is probably a better way to do it.
What are you trying to do?
精彩评论