Ziyad
Ziyad

Reputation: 157

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?

Upvotes: 0

Views: 177

Answers (3)

Toto
Toto

Reputation: 91385

  • 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

Upvotes: 2

Black Mamba
Black Mamba

Reputation: 15545

Here's regex I used in VSCode to find and replace to get your task done:

(.*)?-\d.*

And replace with $1 Not sure about notepad++ but should get it done for you as well.

Upvotes: 1

Anthony Poon
Anthony Poon

Reputation: 887

Use regex to find and replace

Find: ^(.+)-\d.*$

Replace: $1

Upvotes: 1

Related Questions