Page 1 of 1
Delete line with 3 or more same charaters?
Posted: Sat Mar 10, 2012 5:53 am
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.
Re: Delete line with 3 or more same charaters?
Posted: Sat Mar 10, 2012 10:55 pm
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
Re: Delete line with 3 or more same charaters?
Posted: Sun Mar 11, 2012 12:24 am
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]
Re: Delete line with 3 or more same charaters?
Posted: Tue Mar 13, 2012 8:59 am
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.
Re: Delete line with 3 or more same charaters?
Posted: Wed Mar 14, 2012 6:51 pm
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 ]
Re: Delete line with 3 or more same charaters?
Posted: Wed Mar 14, 2012 10:03 pm
by DataMystic Support
Then use
Code: Select all
[ capture(letter), 0+ not cr or lf, group1, 0+ not cr or lf, group1 ]
Re: Delete line with 3 or more same charaters?
Posted: Sat Mar 17, 2012 12:28 am
by lalpha8sorter
Excellent, that works thank you