Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/232.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php REGEX将获得;任何“U字符((数字、数字))”;_Php_Regex_Preg Match All - Fatal编程技术网

Php REGEX将获得;任何“U字符((数字、数字))”;

Php REGEX将获得;任何“U字符((数字、数字))”;,php,regex,preg-match-all,Php,Regex,Preg Match All,我有这种类型的字符串: some text that can contains anything ((12.1,5.2))another text that can contains anything ((1,8.7)) and so on... 事实上,我不知道如何得到: [0]某些文本可以包含任何内容((12.1,5.2)) [1] 另一个可以包含任何内容的文本((1,8.7)) 我试过:preg\u match\u all(“#(.*”(\([0-9\.]+,[0-9\.]+).*))

我有这种类型的字符串:

some text that can contains anything ((12.1,5.2))another text that can contains anything ((1,8.7)) and so on...
事实上,我不知道如何得到:

[0]某些文本可以包含任何内容((12.1,5.2))

[1] 另一个可以包含任何内容的文本((1,8.7))

我试过:
preg\u match\u all(“#(.*”(\([0-9\.]+,[0-9\.]+).*))。”,$lines,$match)但肯定不行。
我还尝试添加“U”选项和?在*和+之后,但没有更多结果


谢谢

您可以将此正则表达式与
preg\u match\u all
一起使用:

/.*?\(\([\d.,]+\)\)/

试着在你拥有的东西上使用这种变化:

 preg_match_all('#.*?\(\([0-9.]+,[0-9.]+\)\)#',$lines,$match);
在开始处加上问号很重要,否则圆点也会占用开始括号。我还删除了结束括号后的部分,假设您的下一行从那里开始

此外,您不需要整个捕获组

以下

 if ($match !== false) {
      var_export ($match[0]);
 }
将输出:

array (
  0 => 'some text that can contains anything ((12.1,5.2))',
  1 => 'another text that can contains anything ((1,8.7))',
)

当括号内有2个以上的数字时,这将匹配。我还有另一个问题,因为我的文本是多行的,我需要添加“s”选项。谢谢