Thread Closed 
 
Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Limiting the consecutive occurrence
05-28-2012, 06:55 AM (This post was last modified: 05-28-2012 08:40 AM by Pixel.)
Post: #33
RE: Limiting the consecutive occurrence
(05-28-2012 06:43 AM)M@LIK Wrote:  @Pixel:: I believe this is what you want:
Code:
A BUG found!

I don't what you people trying to do...
I'm just the scripting guy!! xD

EDiT:
"A BUG found!"
Try this one:
Code:
sed "/\(.\)\1\1/d;/\(.\).*\1.*\1/d;/\(.\).*\1.*\(.\).*\2/d;/\(.\).*\(.\).*\1.*\2/d"

That was quick, you are a sed scripting god M@LIK Big Grin Thanks

M@LIK, it not working as I'd hoped

Code:
AABACDEF
AABACDEG
AABACDEH
AABACDEI
AABACDEJ
AABACDEK

breaks this rule

No more than 2 of any character within a single line


Edit: I got it working but can't be sure as I don't understand the command at all but notice you added
Code:
/\(.\).*\1.*\(.\).*\2/d

and
Code:
/\(.\).*\(.\).*\1.*\2/d

so I remove one of them. The command I using that seems to work is

Code:
sed "/\(.\)\1\1/d;/\(.\).*\1.*\1/d;/\(.\).*\1.*\(.\).*\2/d"

and output is

Code:
AABCDEFG
AABCDEFH
AABCDEFI
AABCDEFJ
AABCDEFK
AABCDEFL

these extra commands have slowed it down even more lol, shame they is no GPU version of sed or even a mulit-core version Smile
Find all posts by this user
Thread Closed 


Messages In This Thread
RE: Limiting the consecutive occurrence - Pixel - 05-28-2012 06:55 AM