I have an employees table which has a column of employee names. It looks like this:
I want to use a replace function so that the names of the employees become "Alxen," "Milxer" and "Mulxa." So that the second 'L' of the name is replaced with "X."
The answer to the question is simply to use regexp_replace(employee_name,'LL','LX',1,1). This will replace just the first occurrence of the LL pattern with LX. If he needs to replace all occurrences of LL (if multiples exist in the string), then use regexp_replace(employee_name,'LL','LX',1,0).
Dig Deeper on Using Oracle PL-SQL
Related Q&A from Karen Morton
Learn how to do simple SQL arithmetic operations without using the arithmetic operators. Continue Reading
One reader asks if it is the best practice to store a document inside an Oracle database. Continue Reading
One reader asks how to create and retrieve a binary large object (BLOB), and SQL expert Karen Morton gives some comprehensive advice and tips. Continue Reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.