1

I have a file with a structure like:

some text and numbers and a final number: 1.213,31
some other number 1231 and text 

again some text and a final number: 53,00
something else
again a final number: 1.233,54

Now I want to create a file looking like:

1.213,31
53,00
1.233,54

I can use higlight-regexp and the regexp [0-9,.]+$ to match the correct content, but I don't know how to remove the rest of the file or alternatively copy everything higlighted by this regexp into another buffer.

So how can I do this?

2 Answers 2

1

Just use query-replace-regexp with .*?\([0-9\,\.]+\)$ → \1. And then keep-lines with the same regexp.

1

alternatively copy everything [matching] this regexp into another buffer.

You can do that with occur

C-uM-so : \([0-9,.]+\)$ RET \1 RET

Or, if less-specific is fine, just:

C-uM-so [0-9,.]+$ RET

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.