Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: Regular expression for a comma separated string

by naderra (Novice)
on Nov 24, 2014 at 00:10 UTC ( #1108199=note: print w/replies, xml ) Need Help??


in reply to Re: Regular expression for a comma separated string
in thread Regular expression for a comma separated string

It doesn't have to be. I didn't mention earlier, I did try to break it down but with no success.
/^(?=[ACGT]{1,4},[ACGT]{1,4}$).*$/ && /^(?!.*(.).*\1.*,).*$/ && /^(?!,.*(.).*\1).*$/

Replies are listed 'Best First'.
Re^3: Regular expression for a comma separated string
by Anonymous Monk on Nov 24, 2014 at 00:43 UTC
    Well then, I'd do it like that
    my @lst = qw( A,G AG,CT TC,CA GAT,CGA CGAT,TG ,G ACGT X,A AA,G AC,GGC ATGA,TGG ATCXG,AAC ATA,TG GTA,YC); for (@lst) { my $good = do { m/^ [ATCG]+ , [ATCG]+ $/x and not grep m/(.) .* \1/x, split ','; }; print $_, $good ? ' good' : ' bad', "\n"; }
    Output:
    A,G good AG,CT good TC,CA good GAT,CGA good CGAT,TG good ,G bad ACGT bad X,A bad AA,G bad AC,GGC bad ATGA,TGG bad ATCXG,AAC bad ATA,TG bad GTA,YC bad

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1108199]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (1)
As of 2023-06-08 02:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you go to conferences?






    Results (29 votes). Check out past polls.

    Notices?