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.
如果我想从这样的 URL 中提取“-i123213131345”,我必须使用什么正则表达式 http://example.com/blabla-bla-i123213131345/blabla
http://example.com/blabla-bla-i123213131345/blabla
尝试-i[0-9]+模式。
-i[0-9]+
样本:
$str = 'http://example.com/blabla-bla-i123213131345/blabla'; $pattern = '/-i[0-9]+/'; preg_match($pattern, $str, $matches); var_dump($matches);
演示
这是在实现正则表达式之前使用它们的有用工具。对学习也有很大帮助Regex。
Regex