
I'm not guessing, I looked it up ;) By default, a quantified subpattern is "greedy", that is, it will match as many times as possible (given a particular starting location) while still allowing the rest of the pattern to match. If you want it to match the minimum number of times possible, follow the quantifier with a "?". Note that the meanings don't change, just the "greediness": *? Match 0 or more times +? Match 1 or more times ?? Match 0 or 1 time {n}? Match exactly n times {n,}? Match at least n times {n,m}? Match at least n but not more than m times in a terminal do 'perldoc perlre' for full explanation :) -Kenny On Thu, 16 Apr 2009, lieven sterck wrote:
I'm guessing only after a quantifier ..
L.
Esther-Kristin Lather wrote:
I guess my problem is solved... ; -)
(but one question remains in my head: So I can use the ? for non-greedy search only after a quantifier? Or also if I group something with round brackets?)
Jonathan Gordon wrote:
............................................________........................
....................................,.-??...................``~.,..................
.............................,.-?...................................?-.,............
.........................,/...............................................?:,........
.....................,?......................................................\,.....
.................../...........................................................,}....
................./......................................................,:`^`..}....
.............../...................................................,:?........./.....
..............?.....__.........................................:`.........../.....
............./__.(.....?~-,_..............................,:`........../........
.........../(_....?~,_........?~,_....................,:`........_/...........
..........{.._$;_......?=,_.......?-,_.......,.-~-,},.~?;/....}........... ...........((.....*~_.......?=-._......?;,,./`..../?............../............
...,,,___.\`~,......?~.,....................`.....}............../.............
............(....`=-,,.......`........................(......;_,,-?...............
............/.`~,......`-...............................\....../\...................
.............\`~.*-,.....................................|,./.....\,__...........
,,_..........}.>-._\...................................|..............`=~-,....
.....`=~-,_\_......`\,.................................\........................
...................`=~-,,.\,...............................\.......................
................................`:,,...........................`\..............__..
.....................................`=-,...................,%`>--==``.......
........................................_\..........._,-%.......`\...............
...................................,<`.._|_,-&``................`\.............. lieven sterck wrote:
if there wasn't an ocean separating us, I would smack you!!! O:-) L.
Thomas Abeel wrote:
I would paste it in Word, replace the spaces with a tabs, select the whole thing, copy it and paste it in Excel. Then select the column you need.
That's what I call KIS. No need to mess around with Perl
lieven sterck wrote:
aaahh, 8-) , the many ways of PERL !!!
Sebastian Proost wrote:
> Esther-Kristin Lather schreef: > > > > > > 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? > > > > Thanks for any suggestions! > > Esther. >> _______________________________________________ > > Binari Implicitly Neglects All Recursive Iterations > > https://maillist.psb.ugent.be/mailman/listinfo/binari > > > > > > > > > > > > > use split ;) > > > > > -- ============================================================== Lieven Sterck, PhD
Tel:+32 (0)9 3313821 Fax:+32 (0)9 3313809 VIB Department of Plant Systems Biology, UGent Bioinformatics and Evolutionary Genomics Division Technologiepark 927, B-9052 Gent, Belgium Email: lieven.sterck@psb.vib-ugent.be Website: http://bioinformatics.psb.ugent.be
============================================================== "Facts are meaningless. You could use facts to prove anything that's even remotely true!" H. Simpson
------------------------------------------------------------------------
_______________________________________________ Binari Implicitly Neglects All Recursive Iterations https://maillist.psb.ugent.be/mailman/listinfo/binari
_______________________________________________ Binari Implicitly Neglects All Recursive Iterations https://maillist.psb.ugent.be/mailman/listinfo/binari
-- ============================================================== Lieven Sterck, PhD
Tel:+32 (0)9 3313821 Fax:+32 (0)9 3313809 VIB Department of Plant Systems Biology, UGent Bioinformatics and Evolutionary Genomics Division Technologiepark 927, B-9052 Gent, Belgium Email: lieven.sterck@psb.vib-ugent.be Website: http://bioinformatics.psb.ugent.be
============================================================== "Facts are meaningless. You could use facts to prove anything that's even remotely true!" H. Simpson ------------------------------------------------------------------------
_______________________________________________ Binari Implicitly Neglects All Recursive Iterations https://maillist.psb.ugent.be/mailman/listinfo/binari
_______________________________________________ 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