This question already has an answer here:
what regular expression i must use if i want to extract "-i123213131345" from URL like this http://example.com/blabla-bla-i123213131345/blabla
http://example.com/blabla-bla-i123213131345/blabla
</div>
Try -i[0-9]+ pattern.
-i[0-9]+
Sample:
$str = 'http://example.com/blabla-bla-i123213131345/blabla'; $pattern = '/-i[0-9]+/'; preg_match($pattern, $str, $matches); var_dump($matches);
Demo
Here's useful tool to play with regexes before you implement them. Also it helps a lot to learn Regex.
Regex