Q

Replacing text strings in an employee name column

One reader asks how he can change occurrences of "LL" to "LX" in an employee name column.

I have an employees table which has a column of employee names. It looks like this:

employee_name
  ALLEN
  MILLER
  MULLA

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).

This was first published in October 2011

Dig deeper on Using Oracle PL-SQL

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide

SearchDataCenter

SearchContentManagement

SearchFinancialApplications

Close