-1

I need to edit lines in a text file.

The text files contains more than 100 lines of data in the below format.

 Cosmos Rh Us (Paperback)   $10.99   Shipped: 
 The Good Earth (Paperback) $6.66    Shipped: 
 BEST OF D.H. LAWRENCE (Paperback) $7.89 Shipped:
 ...

These are excerpts from the online book shop I use to buy books

I have this data in a test editor. How do I edit it [Fine/Replace] such that the data becomes like this

  $10.99
  $6.66
  $7.89

or better, without the dollar sign, since it'll be easy total it.

I use notepad++ as text editor.

user2434
  • 6,339
  • 18
  • 63
  • 87

4 Answers4

2

Search for (don't forget to enable regular expressions in the replace box!)

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

and replace all with

\1
Tim Pietzcker
  • 328,213
  • 58
  • 503
  • 561
1

You could simply match full lines and capture all numbers after the $ sign:

Find what: ^[^$]*\$(\d+\.\d+).*$
Replace with: $1

Make sure that you don't check the ". matches newline" option. And note that this will behave unexpectedly if you have multiple $ signs in a line.

You might need to update to Notepad++ 6. Before that some regex features were not working properly.

Martin Ender
  • 43,427
  • 11
  • 90
  • 130
0

Find:

((?<=\$)[\d\.]+)

Replace With:

\1 or $1 (whichever Notepad++ uses)

garyh
  • 2,782
  • 1
  • 26
  • 28
0

first regex will be replaced with nothing

[a-zA-Z0-9].*\)

second regex will be replaced with nothing

[a-zA-Z]+\:
Saddam Abu Ghaida
  • 6,381
  • 2
  • 22
  • 29