This is first php code
$bbtext = "<br/><br/>This [color=red]is [b]bold[/b] and this is [u]underlined[/u] and [color=green]this [/color]is in [i]italics[/i] with[/color] a [color=red] red color[/color]";
preg_match_all('/\[color=(.*?)\]/', $bbtext, $matches, PREG_OFFSET_CAPTURE);
print_r($matches);
the above php code output is, Output 1
Then, other php code
$pattern = '/abcd/';
$string = 'weruhfabcdwuir';
preg_match($pattern, $string, $matches, PREG_OFFSET_CAPTURE);
print_r($matches);
output is, Output 2
In second php code, abcd is start from 6th index position. (we know that index always starts from 0). It is working correctly on php output.
In first php code, [color=red] is start from 5th index position. but, output is shown as 15.
why this difference occurred on output 1?