Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove a character from a given position on Oracle

Is there anyway to remove a character from a given position?

Let's say my word is: PANCAKES And I want to remove the 2nd letter (in this case, 'A'), so i want PNCAKES as my return.

Translate doesnt work for this. Replace doesnt work for this. Regex is damn complicated...

Ideas?

like image 358
alex Avatar asked Feb 18 '26 22:02

alex


1 Answers

Example:

SUBSTR('PANCAKES', 0, INSTR('PANCAKES', 'A', 1, 1)-1) || SUBSTR('PANCAKES', INSTR('PANCAKES', 'A', 1, 1)+1)

I don't have an Oracle instance to test with, might have to tweak the -1/+1 to get the position correct.

References:

  • INSTR
  • SUBSTR
  • Concatenating using pipes "||"
like image 89
OMG Ponies Avatar answered Feb 21 '26 13:02

OMG Ponies



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!