Need to match multiple backslahes in a PHP regex -
Need to match multiple backslahes in a PHP regex -
i'm trying match 4 backslahes using preg_match.
preg_match('/\\\\\\\\/',$subject)
works fine, preg_match('/\\{4}/',$subject)
doesn't.
perhaps i'm using {} incorrectly. advise?
ok got it: 2 backslashes mean want 1 backslash in string: regex looks this: /\{4}/
means want escape {
what need here is:
preg_match('/\\\\{4}/', $subject);
that looks regex this: /\\{4}/
, works properly.
php regex preg-match
Comments
Post a Comment