I'm trying to match 4 backslahes using preg_match.
preg_match('/\\\\\\\\/',$subject)
works fine, but preg_match('/\\{4}/',$subject)
doesn't.
Perhaps I'm using {} incorrectly. Could anyone advise?
I'm trying to match 4 backslahes using preg_match.
preg_match('/\\\\\\\\/',$subject)
works fine, but preg_match('/\\{4}/',$subject)
doesn't.
Perhaps I'm using {} incorrectly. Could anyone advise?
Ok I got it: Two backslashes mean you want one backslash in your string: So for the regex it looks like this: /\{4}/
Which means you want to escape the {
What you need here is:
preg_match('/\\\\{4}/', $subject);
That looks for the regex like this: /\\{4}/
and works properly.