Answer the question
In order to leave comments, you need to log in
Why does the regex only capture the first element?
text:
Number 560
Size range: 42 88,44,46
# Price: 400 rubles 400 kop. PCS.
Location: 2A-75 block A
/(?<=ряд:\s)(?:\d+)/gm
outputs only 42 , but I need to capture all numbers until the end of the line
42
88
44
46
explain plz
Answer the question
In order to leave comments, you need to log in
$str = 'Число 560
Размерный ряд: 42 88,44,46
#Цена: 400 руб 400коп. шт.
Место: 2А-75 корпус А';
preg_match('/ряд:.+/', $str, $m);
preg_match_all('/\d+/', $m[0], $r);
print_r($r[0]);
preg_match_all('/(?:\G(?!^)|ряд:)[\s,]\K\d+/', $str, $r);
so
/(?<=ряд:\s)(?:\d+)(?:[^\d]+\d+)*/gm
what kind of result are you expecting?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question