Why does the following regular function call return a value of 1
:
preg_match('<strong>', '<strong[\>\s]+')
According to the documentation , I would have thought they ought to be reversed.
<strong>
is a regular expression with angle brackets as delimiters . The actual regex is just the strong
part, which successfully matches against the subject string since it has no ^
and $
anchors.
This will fail:
preg_match('/<strong>/', '<strong[\>\s]+')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.