Char/byte positions of delimiters in file

I have a pipe delimited file and I'm trying to write a script that will give the character/byte positions of each pipe in the file. There may be some simple way but I don't know what it is... Can someone help with this?

Ex: file has output below

abc|def|ghi|

I want the script to tell the char positions of the pipes:

4,8,12

Is this a homework assignment? Homework and coursework questions can only be posted in the Homework & Coursework forum under special homework rules.

If this is not homework, please explain why you need to do this.

What operating system and shell are you using?

And, please show us what you have tried to solve this on your own (in CODE tags).

Are you looking for byte counts, character counts, or both. Depending on what tools you're using, bytes counts will be easier or harder than character counts. What tools do you intend to use?