If you already have the $output (the part that Sanford mentioned), I'd say that you can also do something along these lines:
#set( $output = $input.replaceAll( $regex, "$1\u001e$2\u001e$3" ).split("\u001e") )
#set( $outputA = $output[0] )
#set( $outputB = $output[1] )
#set( $outputC = $output[2] )
... View more