In this example i have large string with many defined elements in it part of example string here. In this example i get matches from example file (Starting from first(~32) tilde, to ~120 3), which sloud be correct in my regex, but i need update regex so it get first closest match in reverse from ~120 3, so the result be:
PRIEDE EGLE BERZS LAPU KOKI
<?php
$regex = '/~[1-9](.*?)\~120 3/s';
preg_match($regex, $str, $matches);
echo '<pre>';
print_r($matches);
exit();
?>
So the question is: How should i set direction to get part of string in "reverse"? If i match ~120 3, then i get all results from ~120 3 in reverse until i match tilde symbol+number - ~[1-9]?
Attached image of my currect regex result and marked few elements: * Green - element which i know and in my imagination - will start search in reverse. * Grey - the correct result. * Red - firest match what was found in reverse from ~120 3
Thanks for recommendations in advance!