• Login
Community
  • Login

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

Scheduled Pinned Locked Moved General Discussion
6 Posts 3 Posters 359 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
    S Souza
    last edited by Apr 29, 2020, 3:26 AM

    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

    A 1 Reply Last reply Apr 29, 2020, 3:46 AM Reply Quote 0
    • A
      astrosofista @S Souza
      last edited by Apr 29, 2020, 3:46 AM

      Hi @S-Souza

      Try with $0L in the Replace with field.

      Hope this helps.

      1 Reply Last reply Reply Quote 3
      • S
        S Souza
        last edited by Apr 30, 2020, 11:00 PM

        Hi astrosofista,

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

        Kind Regards

        A 1 Reply Last reply Apr 30, 2020, 11:16 PM Reply Quote 1
        • A
          astrosofista @S Souza
          last edited by Apr 30, 2020, 11:16 PM

          @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
            S Souza
            last edited by May 6, 2020, 4:47 AM

            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

            G 1 Reply Last reply May 6, 2020, 8:14 AM Reply Quote 0
            • G
              gerdb42 @S Souza
              last edited by May 6, 2020, 8:14 AM

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