AWK how to change delimiter while outputting

Hello I need some help in outputting Fields when the delimiter has changed:

echo "test1,test2 | test3,test4,test5" | awk -F"," '{print $1,"COUNT",$2,$4}'

prints out:
test1 COUNT test2 | test3 test5

But how to change the -F"," to -F"|" delimiter, so that it separates the
fields from $2 into the only the word test2.

in result it should print:

test1 COUNT test3 test5

How cant I do that.

brgds from
sdohn

Hi,

If your version of awk supports regexes as FS, try this:

$ echo "test1,test2 | test3,test4,test5" | awk -F"[,|]" '{print $1,"COUNT",$2,$4}'
test1 COUNT test2  test4

Thanks a lot user ripat, it just works.
I didn't thought that this is so easy.

greetings from
sdohn