
On Thu, 16 Apr 2009, Esther-Kristin Lather wrote:
Hi!
How can I make this Regex greedy?
my ($seq) = ($var =~m/^(.*_{0,1}\d+)\s.*/);
if $var is "ara_prot.tfa_3154 | AT1G26170.1 | no family", I want to cut after the first whitespace so that $seq becomes be "ara_prot.tfa_3154" and not "ara_prot.tfa_3154 | AT1G26170.1".
I don't know where/ how to include the ? for non-greedy search. I would want to do it with round brackets, but that violates the round brackets I already use for getting a part of the string, no?
I don't really understand why you need a regex for this. Can't you split /\|/, $var; and afterwards check if the first part matches your regex?
Thanks for any suggestions! Esther. _______________________________________________ Binari Implicitly Neglects All Recursive Iterations https://maillist.psb.ugent.be/mailman/listinfo/binari
-- ================================================================== Kenny Billiau Web Developer Tel:+32 (0)9 331 36 95 fax:+32 (0)9 3313809 VIB Department of Plant Systems Biology, Ghent University Technologiepark 927, 9052 Gent, BELGIUM kenny.billiau@ugent.be http://bioinformatics.psb.ugent.be ================================================================== "Never get out of the boat" -- Chef, APN