For example, I have the following code:
$string = "adf gggg eere value aaaa bbb (10) value
ddttt ggg www (20) value ddttt ggg www dddd (40) ";
preg_match("/(value).*(\(\d+\))/is", $string, $result);
var_dump($result[2]);
I am trying to get the first value (10). The above code outputs 40, which makes sense, but not what I want. String pattern: the word "value", then the number of any characters, then "(", the integer ")". It seems that I am missing something obvious ... I have not worked too much with regular expressions, but I believe that it can be somehow solved with help ?<!valueuntil it succeeds.
Thanks for any help.
source
share