我正在尝试使用php从括号()之间的字符串中获取一些数据。
我正在尝试使用带有函数preg_split()的正则表达式。
string = franco (franco@gmail.com), juan (juan@gmail.com), dario (dario@gmail.com), laura (guzman@gmail.com).
哪个是正则表达式?
答案 0 :(得分:0)
您可以使用:
$string = 'franco (franco@gmail.com), juan (juan@gmail.com), dario (dario@gmail.com), laura (guzman@gmail.com).';
preg_match_all('/\(\K[^)]+/', $string, $m);
print_r($m[0]);
正则表达式分手:
\( # match a literal (
\K # reset matched information
[^)]+ # match 1 or more characters that is not )
<强>输出:强>
Array
(
[0] => franco@gmail.com
[1] => juan@gmail.com
[2] => dario@gmail.com
[3] => guzman@gmail.com
)