I've ubuntu installed inside windows . Is there any way I can keep the ubuntu installation intact while formatting the windows ?
If you have Ubuntu installed under Windows, then you are using a virtual machine which will be a program installed on Windows. The only way I see will be to save the "virtual hard disk" your virtual machine uses. After reinstalling, you should be able to use it to boot. See the configuaration of your virtual machine. But I've never tried it.
But the best will be to do a proper installation of Ubuntu.
This question is already answered in askubuntu
Another option is backup the wubi installation using remastersys ,and install it alongside Ubuntu using remastered iso
Remastersys is a tool that can be used to do 2 things with an existing Debian, Ubuntu or derivative installation.
It can make a full system backup including personal data to a live cd or dvd that you can use anywhere and install. It can make a distributable copy you can share with friends. This will not have any of your personal user data in it.
The resulting iso file can be used on any other PC that still meets the original minimum requirements of Ubuntu or Debian. Things like the graphics card and other hardware will be configured and setup automatically and you do not have to use identical hardware. Ubuntu's live boot tool, casper, currently blacklists Nvidia and AMD proprietary drivers so they will not be available on the live system and will need to be reinstalled after installation of your custom system