简体   繁体   中英

Unknown letter preg_match

Just quick question, I'm using preg_match to get a information from the URL, but I found a problem.

The letters "avadasa" are always different, how I can tell the script that this is not important. I want my script to skip it and leave just "Name-Of-Article"

http://example.com/ avadasa /Name-Of-Article

Thanks for help

$url = "http://example.com/avadasa/Name-Of-Article";
preg_match('#^http://(?:www\.)?example\.com/[^/]+/([\w-]+)$#', $url, $match);
$name_of_article = $match[1];
echo $name_of_article;

DEMO

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM