<div class="test" style="margin-bottom:10px">
</div>const range = arr => arr
.sort((a, b) => a - b)
.reduce((agg, v) => {
const currRange = agg[agg.length - 1]
if (!currRange || v > currRange.last + 1) {
agg.push({first: v, last: v})
} else {
currRange.last = v
}
return agg
}, [])
.map(v => v.first + (v.first !== v.last ? '-' + v.last : '')).join()
\[(?<id>id(?<idNumber>.*?))\|(?<notify>@(?<name>.*?))\]Group `id` id296954377
Group `idNumber` 296954377
Group `notify` @wert43211
Group `name` wert43211$re = '/\[(?<id>id(?<idNumber>.*?))\|(?<notify>@(?<name>.*?))\]/m';
$str = '[id296954377|@wert43211]';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);