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