- mb_strpos: documentation ( source)
- mb_strlen: documentation ( source)
- preg_match: documentation ( source)
- preg_match_all: documentation ( source)
- var_export: documentation ( source)
<?php
$str = "příliš žluťoučký img_9 kůn úpěl ďábelské ódy";
var_export(mb_strpos($str, 'img_'));
echo "\n";
var_export(preg_match_all('/\G(?!img_\d)\X/u', $str, $m));
echo "\n";
$mbLength = preg_match_all('/\G(?!img_\d)\X/u', $str, $m);
var_export(mb_strlen($str) !== $mbLength ? $mbLength : 'not found');
echo "\n";
var_export(
preg_match('/\X*?(?=img_\d)/u', $str, $m) ? mb_strlen($m[0]) : 'not found'
);