I have this type of string:
some text that can contains anything ((12.1,5.2))another text that can contains anything ((1,8.7)) and so on...
And in fact I don't know how to get :
[0] some text that can contains anything ((12.1,5.2))
[1] another text that can contains anything ((1,8.7))
...
I tried: preg_match_all('#(.*\(\([0-9\.]+,[0-9\.]+\)\).*?)#',$lines,$match);
but for sure it doesn't work. I also tried to add "U" option and ? after * and + but with no more results.
Thanks
Try with this variation on what you have:
preg_match_all('#.*?\(\([0-9.]+,[0-9.]+\)\)#',$lines,$match);
The added question mark near the start is important , otherwise the dot will also consume the opening brackets. I also removed the part after the closing brackets, assuming your next line starts there.
Also you do not need the overall capture group.
The following
if ($match !== false) {
var_export ($match[0]);
}
will output:
array (
0 => 'some text that can contains anything ((12.1,5.2))',
1 => 'another text that can contains anything ((1,8.7))',
)