20

I want to replace this with gedit:

 1299465 |  2003415 | 2015-09-06 05:35:34.59662+02
 1299449 |  2009400 | 2015-09-06 05:35:32.301683+02
 1299450 |  2008465 | 2015-09-06 05:35:32.451393+02
 1299457 |  2015211 | 2015-09-06 05:35:33.451049+02

to that:

2003415
2009400
2008465
2015211

How can I do this with gedit?

Background: I want to do it with gedit and not sed/python/.... since the replace needs to be done interactive.

  • So you want to strip off the outer fields? – Oli Sep 8 '15 at 14:18
  • @Oli yes I want to strip off the first and third column – guettli Sep 9 '15 at 13:45
44

From the standard Replace box (Control+H) you can use a little grouped regex to handle this:

  • Search for: .*\| (.*) \|.*
  • Replace with: \1
  • Check the box that has "Match as regular expression"

This is on Gedit 3.10.4, the default version in Ubuntu 14.04.

  • not working with no other plugins – AlexGreg Sep 8 '15 at 14:22
  • @AlexGreg Huh? This is with stock gedit on 14.04 as far as I can tell. I've nuked ~/.config/gedit and it still works. – Oli Sep 8 '15 at 14:31
  • well..not my case..weird – AlexGreg Sep 8 '15 at 14:34
  • 1
    @AlexGreg It works, you have to check the "Regular expression" checkbox tough – kos Sep 8 '15 at 14:37
  • 3
    Sounds like you're using an ancient version of Ubuntu, @AlexGreg. Even 12.04 Precise —the oldest supported version of Ubuntu— is using 3.4.1. – Oli Sep 8 '15 at 14:46
4

You can use the plugin advanced-find for gedit.

Install the plugin from here.

The instructions (if you don't know it already) on how to implement a gedit plugin is here

Then, use Oli's answer to strip the numbers you want from your question.

  • If you are running Mint, you will likely have an old version of gedit and then this is the best answer. – mcarans Jun 17 '16 at 8:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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