Use regex in postgres I want to use regexp_replace() to replace the string 


  name1-01.name2-02.1


to


  name1.01-name2.02.1


How to use the regex here?
select regexp_replace('name1-01.name2-02.1','(.*)-(\d+)\.(.*)-(.*)','\1.\2-\3.\4');


Assuming:


Everything before the first '-' can contain anything but '-'. 
There's always a number after the first '-' 
'name2' doesn't contain a '-'


Just guessed your requirements, basically. Might be wise for you to read a regular expression tutorial.