Notepad++ Replace regex match for same text plus appending character

后端 未结 3 911
我寻月下人不归
我寻月下人不归 2020-12-13 08:16

I have a file with text and numbers with a length of 5 (i.e. 12000, 11153, etc.). I want to append all of these numbers with a 0. So <

相关标签:
3条回答
  • 2020-12-13 08:45

    You are very close. You need to add a capturing group to your regex by surrounding it with brackets. ([0-9]{5})

    Then use \10 as the replacement. This is replacing the match with the text from group 1 followed by a zero.

    0 讨论(0)
  • 2020-12-13 08:52

    You are very near to the answer! What you missed is a capturing group.

    Use this regex in "Find what" section:

    ([0-9]{5})

    In "Replace with", use this:

    \10

    The ( and ) represent a capturing group. This essentially means that you capture your number, and then replace it with the same followed by a zero.

    0 讨论(0)
  • 2020-12-13 08:52

    You can use \K to reset.

    \b\d{5}\b\K
    

    And replace with 0

    • \b matches a word boundary
    • \d is a short for digit [0-9]

    See demo at regex101

    0 讨论(0)
提交回复
热议问题