我有这段文字:
之前的内容
[row marginTop="10" marginBottom="10"]
[column_3]
[column][article id="12" /][/column]
[column][article id="13" /][/column]
[column][article id="14" /][/column]
[/column_3]
[/row]
当我这样做时:
$pattern = '/^(\[([a-zA-Z0-9][a-zA-Z0-9_]+[a-zA-Z0-9]) *( [a-zA-Z]+( ="[^".]*")?)*( *\/)?\])$/'; preg_match($pattern, $text, $matches, PREG_OFFSET_CAPTURE); print_r($matches);
结果是:
大批
(
[0] => 数组
(
[0] => [行 marginTop="10" marginBottom="10"]
[1] => 137
)
[1] => 数组
(
[0] => marginBottom="10"
[1] => 156
)
[2] => 数组
(
[0] => =“10”
[1] => 166
)
)
为什么?我能做些什么来避免这种情况?