Community
    • Login

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

    Scheduled Pinned Locked Moved General Discussion
    6 Posts 3 Posters 717 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S SouzaS Offline
      S Souza
      last edited by

      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

      astrosofistaA 1 Reply Last reply Reply Quote 0
      • astrosofistaA Offline
        astrosofista @S Souza
        last edited by

        Hi @S-Souza

        Try with $0L in the Replace with field.

        Hope this helps.

        1 Reply Last reply Reply Quote 3
        • S SouzaS Offline
          S Souza
          last edited by

          Hi astrosofista,

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

          Kind Regards

          astrosofistaA 1 Reply Last reply Reply Quote 1
          • astrosofistaA Offline
            astrosofista @S Souza
            last edited by

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

            1 Reply Last reply Reply Quote 2
            • S SouzaS Offline
              S Souza
              last edited by

              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

              gerdb42G 1 Reply Last reply Reply Quote 0
              • gerdb42G Offline
                gerdb42 @S Souza
                last edited by

                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.

                1 Reply Last reply Reply Quote 3

                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
                • First post
                  Last post
                The Community of users of the Notepad++ text editor.
                Powered by NodeBB | Contributors