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

Join the conversationComment

Share
Comments

    Results

    Contribute to the conversation

    All fields are required. Comments will appear at the bottom of the article.