• Login
Community
  • Login

How to transfer wildcards from FIND to REPLACE

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
3 Posts 3 Posters 265 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.
  • D
    Danny Spence
    last edited by Feb 12, 2022, 3:51 PM

    I have a group of dates where i want to make into a comma delimited file and i can FIND the range with something like “Feb/1.” as a Regular Expression. With that, i can find Feb/10, Feb/11, Feb/12, Feb/13, ect, but i dont know the syntax to translate that wildcard (.) over to the REPLACE field. If i FIND “Feb/10” I want it replaced with “Feb/10,”. Each element needs to be represented in the replace expression. All the answers i have found focus on the FIND expression.

    P N 2 Replies Last reply Feb 12, 2022, 5:46 PM Reply Quote 0
    • P
      PeterJones @Danny Spence
      last edited by PeterJones Feb 12, 2022, 7:38 PM Feb 12, 2022, 5:46 PM

      @danny-spence

      FIND = Feb/1.
      REPLACE = ${0},
      SEARCH MODE = regular expression

      The $0 or ${0} in the replacement means “use the enter entire string found in FIND as part of the replacement”. This is documented in the npp-user-manual.org ’s [Searching > Regular Expressions > Substitution section.

      1 Reply Last reply Reply Quote 2
      • N
        Neil Schipper @Danny Spence
        last edited by Feb 12, 2022, 7:33 PM

        @danny-spence You should try to describe in a more precise and complete way all the types of strings you wanted altered. If you are happy doing a separate F&R operation for every date of interest, that’s what Peter’s solution provides. If you wish to alter every Feb date, you need something like Feb/\d+. If you wish to alter a restricted range of dates in Feb like say 8th to 23th, you need something a bit more complex. If you wish to alter every date in the format you’ve shown, you need something like (Jan|Feb|..etc..|Dec)/\d+. Try to eliminate the need for your readers to do guesswork.

        1 Reply Last reply Reply Quote 3
        1 out of 3
        • First post
          1/3
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors