#!/bin/bash
echo "F1,F2,[as1,as2],[as3,as4]" | perl -lpe 's/(\[[^][]+])/$1=~s#,#|#gr/ge'