tags:

views:

52

answers:

4

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:

This is a multiline string, I just printed out this one it is important.

+4  A: 

I don't think you want those outer pluses.

(.+)Because it already exists(.+)
Borealid
+1  A: 

Using this online regular expression tester, I found that Borealid reply totally fulfills your need.

Riduidel
@Riduidel this is not very good tester
Gandalf StormCrow
A: 

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?

Sylverdrag
+2  A: 

More simply :

/Because it already exists/
M42
@M42 not working m8
Gandalf StormCrow
What do you mean by "not working" ?
M42