i have something to accomplish. i need to replace all occurrence of &  inside or between `<ex>` `</ex>` to #. actual example below:

    a & b & c <ex> a & b & c </ex> a & b & c

again, i need to replace all occurrence of &  inside `<ex>` and before `</ex>`

expected output:

    a & b & c <ex> a # b # c </ex> a & b & c

please post the explanation also on how you guys managed to make it.

### EDIT#1
Please only provide me with a `sed` solution since I'm going to run this on an AS400 system and lack the ability to install Perl or any other interpreter.