I only knows basic regex, so I am look for help here.
I need to match URL with this pattern:
/kb/This-is-possible-title-12345.html
The URL will always ends with -nnnnn.html. Currently I have this regex pattern:
'kb/[a-zA-Z_-]*(\\d+)\\.html'
however, this does not work if the portion contains numbers, such as
/kb/This-is-12345-possible-title-12345.html
This needs to be done with PHP preg_match function.
乍看之下您看起来正确,但是您需要转义正斜杠,因此将“ /”更改为“ \\ /”。
以下对我/kb/[\\w_-]*-(\\d+)\\.html$
:/ /kb/[\\w_-]*-(\\d+)\\.html$
. /kb/[\\w_-]*-(\\d+)\\.html$
。
'/kb/[^/]*-\\d{5}\\.html'
这匹配“ / kb /”“除“ /”之外的任何字符”“连字符”“ 5位数字”“ .html”
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.