s/(\d+)/ sprintf('%03d', $1) /eg; [download]
In reply to Re^2: replace text with function ? by ikegami in thread replace text with function ? by 2xlp