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.
Thanks
-
-
Hi astrosofista,
Thank you very much, it works! spent a good half-day trying to figure this out.
Kind Regards
-
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?
Cheers
-
Try the following:
Search for:
(RLK)(\d{2})(?=\D)
Replace with:${1}0${2}LMay I suggest to take a deeper look at Regexes? A good starting point would be here.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login