Answer

Replacing text strings in an employee name column

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

employee_name
 

    Requires Free Membership to View

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

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

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: