Hi, I noticed that .*? in perl and phython, if used at the beginning of an unanchored (without ^) regular expression still behaves half-greedy:
perl: "hello" =~ /(.*?)l/; print "\$1 = $1\n"; python: import re r=re.search("(.*?)l","hello") print "$1=",r.group(1) In both cases, "he" is printed, while the real minimal match obviously would result in an emtpy $1 or r.group(1). This is the behavour if I put the (.*?) at the end (ex.: /h(.*?)/) Is this a bug in perl/python itself, or maybe in the documentation? Or am I misunderstanding something? Should I file bugs? (notice that, when replacing .*? with .*, both perl and python find "hel", so it seems the greedyness to the right-hand-side is controled OK by the ?, but not to the left-hand-side). (Yes, I know I can `fix' it by adding .* to the beginning of the reg-expr). $ dpkg -l python\* perl\*|grep ^i ii python-base 1.5.1-3 An interactive object-oriented scripting lan ii python-doc 1.5.2p1-4 Documentation for the scripting language Pyt ii python-gtk 0.6.5-1 GTK support module for Python. ii python-net 1.5.1-3 TCP/IP and various Internet support modules ii python-tk 1.5.1-3 Tk support module for Python (Tkinter). ii perl-5.004 5.004.05-6 Larry Wall's Practical Extracting and Report ii perl-5.004-bas 5.004.05-6 The Pathologically Eclectic Rubbish Lister ii perl-5.004-sui 5.004.05-6 Runs setuid Perl scripts. ii perl-5.005 5.005.03-7.1 Larry Wall's Practical Extracting and Report ii perl-5.005-bas 5.005.03-7.1 The Pathologically Eclectic Rubbish Lister ii perl-5.005-doc 5.005.03-6 Man pages and pod docs for Perl ii perl-base 5.004.05-1.1 Fake package assuring that one of the -base -- joostje