I got a string like this which is (Joomla all video plugin)
{Vimeo}123456789{/Vimeo}
where 123456789 is variable, how can I extract this? Should I use regex?
If you must use a regular expression, the following will do the trick.
$str = 'foo {Vimeo}123456789{/Vimeo} bar';
preg_match('~{Vimeo}([^{]*){/Vimeo}~i', $str, $match);
var_dump($match[1]); // string(9) "123456789"
This may be more than what you want to go through, but here is a way to avoid regex.
$str = 'foo {Vimeo}123456789{/Vimeo} bar';
$m = substr($str, strpos($str, '{Vimeo}')+7);
$m = substr($m, 0, strpos($m, '{/Vimeo}'));
var_dump($m); // string(9) "123456789"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With