Search code examples
regexnotepad++find-replace

Find and replace in N++


I have a N++ file with the following lines:

asm-java-2.0.0-lib  
cib-slides-3.1.0  
lib-hibernate-common-4.0.0-beta

I want to remove everything from the '-' before the numbers begin so the results look like:

asm-java  
cib-slides  
lib-hibernate-common 

So far I've come up with [0-9]+ but that ignores the '.' and the trailing alphabets. Does anyone know a correct command for find and replace?


Solution

    • Ctrl+H
    • Find what: -\d.*$
    • Replace with: LEAVE EMPTY
    • check Wrap around
    • check Regular expression
    • UNCHECK . matches newline
    • Replace all

    Explanation:

    -       # a dash
    \d      # a digit
    .*      # 0 or more any character but newline
    $       # end of line
    

    Result for given example:

    asm-java
    cib-slides
    lib-hibernate-common