I need to remove the hyphen from the middle so that only the first one remains.

Select ('-SUPER-MAN') from dual 

Desired result: "-SUPERMAN"

  • and if there is more than one hyphen in a line, and for example a hyphen at the end of a line, should it also be removed? - Viktorov
  • Your question is not entirely clear. If "remove the hyphen from the middle so that only the first one remains," that's right, then the answer you received is not correct. All hyphens will be removed there and not only from the middle. Correct please. - 0xdb

2 answers 2

 Select regexp_REPLACE('-SUPER-MAN', '-', '', 2) from dual; 
  • Thank you very much! - Radu Drosu
 with sample as (select '-SUPER-MAN' str from dual) SELECT SUBSTR(str, 1,INSTR(str ,'-', -1)-1)|| SUBSTR(str,INSTR(str ,'-', 1, 2)+1) as ciorticika FROM sample;