Fix + test
This commit is contained in:
Родитель
4acc8bb421
Коммит
b9c9321f10
|
@ -981,7 +981,8 @@ namespace Pchp.Library
|
||||||
{
|
{
|
||||||
var g = groups[i];
|
var g = groups[i];
|
||||||
var value = (g.Success || !unmatchedAsNull) ? g.Value : null;
|
var value = (g.Success || !unmatchedAsNull) ? g.Value : null;
|
||||||
var item = NewArrayItem(value, g.Index, offsetCapture);
|
int index = g.Success ? g.Index : -1;
|
||||||
|
var item = NewArrayItem(value, index, offsetCapture);
|
||||||
|
|
||||||
// All groups should be named.
|
// All groups should be named.
|
||||||
if (g.IsNamedGroup)
|
if (g.IsNamedGroup)
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?php
|
||||||
|
namespace pcre\preg_match_006;
|
||||||
|
|
||||||
|
preg_match('/(?P<fooname>foo)?(bar)/', 'bar', $matches, PREG_OFFSET_CAPTURE);
|
||||||
|
|
||||||
|
$is_fooname = isset( $matches['fooname'] ) && -1 !== $matches['fooname'][1];
|
||||||
|
|
||||||
|
echo "is_fooname:" . ($is_fooname ? "true" : "false") . "\n"; //is_fooname:false
|
Загрузка…
Ссылка в новой задаче