I have a list of 24000 entries. Some lines not all, have a string containing | in them:

680311  Kraszna Kraszna Crasna|Krasna|Kraszna   48.15   22.33333    H   STM HU  00  0   108 Europe/Budapest 2014-07-08
713845  Zsombékosdűlő   Zsombekosdulo   Zsombekos|Zsombékos 47.2    20.01667    P   PPLX    HU  HU  16  0   88  Europe/Budapest 2007-08-27
713828  Zvaradűlő   Zvaradulo   46.85   20.78333    P   PPL HU  03  0   81  Europe/Budapest 2007-08-27
672629  Maros   Maros   Marisus|Mures|Muresh|Muresul|Mureş|Mureşul|mwrysh   46.25   20.2    H   STM HU  HU|RO   00  0   81  Europe/Budapest 2009-04-06
677528  Gémesi Révház   Gemesi Revhaz   46.33472    18.89167    P   PPL HU  00  0   102 Europe/Budapest 2014-07-08
680145  Fekete-Körös    Fekete-Koros    Black Koros|Black Körös|Crisu Negru|Crisul Negru|Crişu Negru|Crişul Negru|Fekete-Koros|Fekete-Körös|Raul Crisu Negru|Râul Crişu Negru   46.7    21.26667    H   STM HU  00  0   88  Europe/Budapest 2012-01-18

The third and fith line is what I'd like to have for all rows, so I'd like to completely remove the strings which have the | in them.

So from this line:

680311  Kraszna Kraszna Crasna|Krasna|Kraszna   48.15   22.33333    H   STM HU  00  0   108 Europe/Budapest 2014-07-08

we'd get:

680311  Kraszna Kraszna 48.15   22.33333    H   STM HU  00  0   108 Europe/Budapest 2014-07-08


There are spaces in the data like in the fifth row with "Gémesi Révház" which should stay, also there are spaces within the strings to be removed, like in the sixth row "Black Koros|Black Körös|Crisu Negru ..." which should go away together with the strings.

I was looking for guides and regex solutions, but I could not find any for this kind of problem.

Can this be done with notepad++ or notepad++ and regex?


New question created because the scope changed to extract one string and two numbers: Notepad++ and regex: extract string and two numbers from list of rows

Will leave this question as is, the discussion might be helpful.


Ctrl+h then

Find with: [ \t]+[^ ]+\|[^ ]+[ \t]+
Replace With:
(In "Replace with" use a single space and do not forget to switch to "regular expression")


The good thing is that realized I only need the second column, the city name plus the location coordinates, which are the first two numbers starting either the 4th or 5th column. I will discard the rest of the data.

It would be much easier then:

Find with: ^\d+\s+([^ ]+)[^0-9]+\s+([0-9\.]+)\s+([0-9\.]+).+$
Replace With: \1 \2 \3

  • Thank you Alex, sorry I should have given a larger sample, the above regex does not work because there are spaces in the string to be removed and also there are some strings in the valid data I'll update the main post in a minute. – xedemx Feb 15 '17 at 10:55
  • @xedemx Update your question with other patterns and let see what we can do – Alex Feb 15 '17 at 10:57
  • @xedemx I afraid that what you want principally impossible to catch, it isn't standardized recordest. We can create pattern that would pick word1 word2|word3 word4 for the lines like line 6, but this pattern will remove in other lines data that shouldn't be removed. I guess that these data was exported from database where was selected option to use tab as delimiter. If you have a choice to export these data as CSV file then it would be much easier to parse such data – Alex Feb 15 '17 at 11:49
  • I would personally search for a any string with | in it which would be a simple .+?\|.+? and replace it with nothing. May need to run this search many times, but eventually it'll remove all strings that contain a | – LPChip Feb 15 '17 at 12:20
  • 1
    @Alex yes, notepad++ DOES support non greedy regex. I didn't know either until recently. Try it and you'll see it works. – LPChip Feb 15 '17 at 14:52

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.