Search code examples
regexnotepad++

How to remove text between numbers in notepad++


I have texts like

3.6. Sam
3.7. Willy

4.1. drake
4.2. nadeem

I need output like

3-6 Sam
3-7 Willy

4-1 drake
4-2 nadeem

I tried replace \d{1}.\d{1}. with \d{1}-\d{1} & later with $1-$2

But I cant retain the number. Can anyone help me with this


Solution

    • Ctrl+H
    • Find what: ^(\d+)\.(\d+)\.
    • Replace with: $1-$2
    • CHECK Wrap around
    • CHECK Regular expression
    • UNCHECK . matches newline
    • Replace all

    Explanation:

    ^       # beginning of line
      (\d+) # group 1, 1 or more digits
      \.    # a dot
      (\d+) # group 2, 1 or more digits
      \.    # a dot
    

    Screen capture (before):

    enter image description here

    Screen capture (after):

    enter image description here