While replacing using regex, How to keep a part of matched string?

前端 未结 2 1601
清酒与你
清酒与你 2020-11-28 07:12

I have

12.hello.mp3
21.true.mp3
35.good.mp3
.
.
.

so on as file names in listed in a text file.

I need to replace only those dots(.

相关标签:
2条回答
  • 2020-11-28 07:22

    Using the basic pattern, well described in the accepted answer here is an example to add the class="odd" and class="even" to every <tr> element in Notepad++ or any other regex compatible editor:

    Find what: (<tr><td>)(.*?\r\n)(<tr><td>)(.*?\r\n)

    Replace with: <tr class="odd"><td>\2<tr class="even"><td>\4

    0 讨论(0)
  • 2020-11-28 07:43

    Replace

    ^(\d+)\.(.*mp3)$
    

    with

    \1 \2
    

    Also, in recent versions of notepad++, it will also accept the following, which is also accepted by other IDEs/editors (eg. JetBrains products like Intellij IDEA):

    $1 $2
    

    This assumes that the notepad++ regex matching engine supports groups. What the regex basically means is: match the digits in front of the first dot as group 1 and everything after it as group 2 (but only if it ends with mp3)

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