[英]PHP Regex for multiple parantheses
I have a string which looks like this: 我有一个看起来像这样的字符串:
43.3433443 25.3434334), (43.32424432 25.435345345, 43.21313123, 25.32432423423), (43.123123123 25.344234234, 43.1234123123 25.23213123))
I need to extract everything that is between ( and ) as well as ( and )) with preg_match_all 我需要使用preg_match_all提取(和)以及(和)之间的所有内容
I have the following regex, which works for extracting everything between ( and ) but not ( and )) 我有以下正则表达式,用于提取(和)之间的所有内容,但不提取(和)之间的所有内容
preg_match_all('/\), \(([A-Za-z0-9., ]+?)\)/', $data[$x], $inner);
I've tried using: 我试过使用:
preg_match_all('/\), \(([A-Za-z0-9., ]+?)\)|\), \(([A-Za-z0-9., ]+?)\)\)/', $data[$x], $inner);
and: 和:
preg_match_all('/(?=\), \(([A-Za-z0-9., ]+?)\))(?=\), \(([A-Za-z0-9., ]+?)\)\))/', $data[$x], $inner);
But none of them have worked. 但是他们都没有成功。 How would I go about to include both cases?
我将如何包括这两种情况?
Thank you. 谢谢。
UPDATE: 更新:
I forgot to mention, the string contains numbers within multiple starting and ending parentheses that I don't want, ie two parantheses ---> (( numbers here ))) <---3 parantheses 我忘了提一下,该字符串包含多个我不需要的括号内的数字,即两个括号--->(((这里的数字)))<--- 3括号
I may be wrong in this, but ()
can be found in ())
, so why not just look for ()
and be done: 我可能错了,但是
()
可以在())
找到,所以为什么不仅仅寻找()
并完成:
<?php
$str = '43.3433443 25.3434334), (43.32424432 25.435345345, 43.21313123, 25.32432423423), (43.123123123 25.344234234, 43.1234123123 25.23213123))';
preg_match_all("/\((.*?)\)/",$str,$matches);
echo '<pre>',print_r($matches),'</pre>';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.