Extracting numeric from string

I have a file whose contents are:
$ cat file1
cfd_V03R37
cfd_V03R38

tried
sed 's/[^0-9]//g' file1 > file2

$cat file1
0337
0338

Is there any way by which i can work on same file and write o/p to the same file instead of using file2

Yes,
use Perl:

perl -i~ -ple'tr/[0-9]//dc' file1

GNU sed supports in place editing.

Yes,
or with tee:

tr -dc '[0-9
]' < file1 | tee file1