<?php
$s = "[test1](test2) testing the regex [test3](test4)";
preg_match_all("/(\[.+?\])(\(.+?\))/i", $s, $m);
var_dump($m[1]);
var_dump($m[2]);
- Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
- array(2) {
[0]=>
string(7) "[test1]"
[1]=>
string(7) "[test3]"
}
array(2) {
[0]=>
string(7) "(test2)"
[1]=>
string(7) "(test4)"
}
preferences:
130.62 ms | 408 KiB | 5 Q