Delete line with 3 or more same charaters?

Get help with installation and running here.

Moderators: DataMystic Support, Moderators, DataMystic Support, Moderators, DataMystic Support, Moderators

Post Reply
lalpha8sorter
Posts: 5
Joined: Sat Mar 10, 2012 5:44 am

Delete line with 3 or more same charaters?

Post by lalpha8sorter »

I have a list from which I need to remove lines which contains 3 or more of the same character anywhere within the line.

I have tried for hours using replace matching word pattern with the following but it just give me an error stating no lines to repeat.

What is most frustrating is more than likely really simple!

Thanks in advance.
lalpha8sorter
Posts: 5
Joined: Sat Mar 10, 2012 5:44 am

Re: Delete line with 3 or more same charaters?

Post by lalpha8sorter »

I have read through http://www.datamystic.com/easypatterns_reference.html and still cannot understand it.

Can anyone help out with it please.

I just basically want to remove any line that has 3 or more of the same character!

Thank you
lalpha8sorter
Posts: 5
Joined: Sat Mar 10, 2012 5:44 am

Re: Delete line with 3 or more same charaters?

Post by lalpha8sorter »

I think I have come up with a solution to sort out lines up to 7 char long however does seem rather long winded.

I'm sure there must be an easier way to delete lines which contain 3 or more of the same character anywhere within the line?


(a)[b-z](a)[b-z](a)[b-z](a)
[b-z][b-z](a)[b-z](a)[b-z](a)
[b-z](a)[b-z][b-z](a)[b-z](a)
(a)[b-z][b-z][b-z](a)[b-z](a)
[b-z](a)[b-z](a)[b-z][b-z](a)
(a)[b-z][b-z](a)[b-z][b-z](a)
(a)[b-z](a)[b-z][b-z][b-z](a)
[b-z](a)[b-z](a)[b-z](a)[b-z]
(a)[b-z][b-z](a)[b-z](a)[b-z]
(a)[b-z](a)[b-z][b-z](a)[b-z]
(a)[b-z](a)[b-z](a)[b-z][b-z]
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Delete line with 3 or more same charaters?

Post by DataMystic Support »

Use a Remove\Matching lines filter, with an EasyPattern of

[ capture(letter), group1, group1 ]

'group1' refers to the text (ie the letter) already captured, so 3 or more duplicate letters will be removed by this.
lalpha8sorter
Posts: 5
Joined: Sat Mar 10, 2012 5:44 am

Re: Delete line with 3 or more same charaters?

Post by lalpha8sorter »

Thanks although That seems to work if the letters are next to each other, but not when on the same line in different columns.

I need a command to delete a line if it has more than three of the same character anywhere on the line, not just next to each.

for example asasasas ,would not be deleted by [ capture(letter), group1, group1 ]
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Delete line with 3 or more same charaters?

Post by DataMystic Support »

Then use

Code: Select all

[ capture(letter), 0+ not cr or lf, group1, 0+ not cr or lf, group1 ]
lalpha8sorter
Posts: 5
Joined: Sat Mar 10, 2012 5:44 am

Re: Delete line with 3 or more same charaters?

Post by lalpha8sorter »

Excellent, that works thank you
Post Reply