if you're hardcoding it into a script, then of course you'd just use $nick(#chan,0,@,+) and $nick(#chan,0,+). otherwise, here's a small demonstration of how i'd do it:
var %z = 1
while ($mid($prefix,%z,1)) {
echo -a $v1 : $nick(#,0,$v1,$gettok(x $prefix x,1,$asc($v1)))
inc %z
}
just added the x`s to make sure a null/wrong parameter was never passed, they wont have any effect

. the idea here is to isolate all the modes before the current one in $prefix, and ensure we dont count them with it