Msg#: 4501190 posted 2:11 am on Sep 29, 2012 (gmt 0)
Obvious question first: does your string
occur on a line all by itself?
Second question: shouldn't it be (php)\\\1 with just three backslashes? That is, two for the literal \ character and one for the "\1" construct? Otherwise you'd be matching the literal string "php\\1" wouldn't you?
Obligatory disclaimer: I don't speak php. But I speak RegEx. After a fashion.
Msg#: 4501190 posted 11:12 am on Sep 29, 2012 (gmt 0)
Yes, the line contains only the string php\php.
I tried with 3 backslashes also, but again, no match was found.I figured that with 4 backslashes, the first 2 match a literal "\", and then the third backslash escapes the backreference "\1" (which is equal to "php"), so all in all you match "php" plus "\" plus "php".
Msg#: 4501190 posted 12:17 am on Sep 30, 2012 (gmt 0)
Oh, what fun. In order to end up with one literal backslash and one \1 element you have to start with three backslashes-- the extra being for the literal backslash-- and then to construct a rule that produces this result, you have to double each individual backslash, for a total of six. And if you ever had to nest this rule inside something else, you'd need twelve backslashes in a row.
So I was on the right track; I just didn't go far enough.
Moral: don't try to match strings containing literal backslashes ;)
When I first started doing e-books, I thought a handy temporary marker for page breaks would be something in the form //123\\ Ouch. But I'm stuck with it.