Ben bu dizeyi ayrıştırmak için çalışıyor:
$right = '34601)S(1,6)[2] - 34601)(11)[2] + 34601)(3)[2,4]';
Aşağıdaki regexp ile:
const word = '(\d{3}\d{2}\)S{0,1}\([^\)]*\)S{0,1}\[[^\]]*\])';
preg_match('/'.word.'{1}(?:\s{1}([+-]{1})\s{1}'.word.'){0,}/', $right, $matches);
print_r($matches);
ben böyle dizi dönmek istiyorum:
Array
(
[0] => 34601)S(1,6)[2] - 34601)(11)[2] + 34601)(3)[2,4]
[1] => 34601)S(1,6)[2]
[2] => -
[3] => 34601)(11)[2]
[4] => +
[5] => 34601)(3)[2,4]
)
ama ben sadece aşağıdaki döndürür:
Array
(
[0] => 34601)S(1,6)[2] - 34601)(11)[2] + 34601)(3)[2,4]
[1] => 34601)S(1,6)[2]
[2] => +
[3] => 34601)(3)[2,4]
)
i think, its becouse of [^)]* or [^]]* in the word, but how i should correct regexp for matching this in another way?
i belirtmek için tryied:
\d+(?:[,#]\d+){0,}
yani kelime haline
const word = '(\d{3}\d{2}\)S{0,1}\(\d+(?:[,#]\d+){0,}\)S{0,1}\[\d+(?:[,#]\d+){0,}\])';
ama hiçbir şey verir