Modify incoming caller id

Hi,

I’m running Asterisk v1.2.13 (modify sip.conf and extension.conf directly) perfectly on my NAS box and I have a Virtual DID from another country to receive calls. In order to make my phone to call back the easily, I want to modify the caller id from Asterisk’s incoming context. Can anyone tell me the easiest way to achieve below rule:

If the caller id already contain 0 as the first number, then no modification needs to make
If the caller id starts from 13 and at least 10 number long, then add 0 in the beginning
If the caller id doesn’t fit into any of above, then add 021 in the beginning

Any suggestion is welcome.

Cheers