How to change telephone format ?

Hi,
I'd like to automatically change the telephone format my clients enter when they ask for a new appointments.
They all type theirs phones in the local format (ex 0652896584) and I'd like to switch it in international format : (+33652896584).
I already make the PHP command I've to use :
$r->phone = preg_replace('0([0-9]{9}$)', '+33$1', $r->phone);

But the thing is that I don't want to directly put it in A+ code, to prevent from re-patching all new versions.

Best regards, Quentin HELLO