Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在努力让 PHP 的正则表达式匹配子目录,但要避免父目录。
http://www.address.com/2000/12/31/-> 不匹配
http://www.address.com/2000/12/31/
http://www.address.com/2000/12/31/whatever/-> 匹配
http://www.address.com/2000/12/31/whatever/
这是我尝试过但似乎不起作用的方法:#http://www\.address\.com/\d{4}/\d{2}/\d{2}/.#
#http://www\.address\.com/\d{4}/\d{2}/\d{2}/.
最后的点只会匹配一个字符,你想要一个或多个:
#http://www\.address\.com/\d{4}/\d{2}/\d{2}/.+#