How to Find regular expression and add a digit to the end

  • Hi guys,

    I need to find regular expression, more specifically all RLK letters follow by any 3 digit numbers, and add a letter L at the end.
    Example: find all RLKxxx and replace with RLKxxxL.

    I have managed to find using: RLK\d{3} but I can’t figure out how to replace with the Find results adding an “L” at the end.


  • Hi @S-Souza

    Try with $0L in the Replace with field.

    Hope this helps.

  • Hi astrosofista,

    Thank you very much, it works! spent a good half-day trying to figure this out.

    Kind Regards

  • @S-Souza

    You’re welcome. The regular expression you posted was correct. But since it didn’t include any capture group, the only way to represented it back was by means of $0, which is a reference to the whole match.

    Best Regards.

  • I’ve just hit another hurdle:

    There are some RLK with only 2 digits in front = RLKxx, I need to add a 0 in between the RLK and first digit, then add the L at the end.

    another weird thing is when I search for RLK\d{2} it shows the RLKxxxL results, how can I exclude those RLKxxxL that I have already changed?


  • Try the following:

    Search for: (RLK)(\d{2})(?=\D)
    Replace with: ${1}0${2}L

    May I suggest to take a deeper look at Regexes? A good starting point would be here.

Log in to reply