Thomas Bätzler schreef: > [ !/^\.$|^\.\.$/ and !/^\.\.?$/ ] > I'm assuming that this regex would be faster, too, since it > does not contain an alternation.
That is hard to say without actual benchmarking: the regex-optimizer gets better with every new version of perl. Check also the re=debug output: $ perl -Mre=debug -e '/^\.\.?$/' Freeing REx: `","' Compiling REx `^\.\.?$' size 9 Got 76 bytes for offset annotations. first at 2 1: BOL(2) 2: EXACT <.>(4) 4: CURLY {0,1}(8) 6: EXACT <.>(0) 8: EOL(9) 9: END(0) anchored `.' at 0 floating `'$ at 1..2 (checking anchored) anchored(BOL) minlen 1 Offsets: [9] 1[1] 2[2] 0[0] 6[1] 0[0] 4[2] 0[0] 7[1] 8[0] Freeing REx: `"^\\.\\.?$"' Note that there is no EOL-test right after the first EXACT <.>. $ perl -Mre=debug -e '/^\.$|^\.\.$/' Freeing REx: `","' Compiling REx `^\.$|^\.\.$' size 11 Got 92 bytes for offset annotations. 1: BRANCH(6) 2: BOL(3) 3: EXACT <.>(5) 5: EOL(11) 6: BRANCH(11) 7: BOL(8) 8: EXACT <..>(10) 10: EOL(11) 11: END(0) minlen 1 Offsets: [11] 0[0] 1[1] 2[2] 0[0] 4[1] 5[1] 6[1] 7[4] 0[0] 11[1] 12[0] Freeing REx: `"^\\.$|^\\.\\.$"' Note that in this case it restarts at BOL if ^\.$ was not matched, so it rechecks the dot at the start. To see more of the workings of the re: $ echo '..' |perl -Mre=debug -wnle '/^\.\.?$/ and print "OK"' Variants, from nice to very ugly: !/^\.\.?$/ !/^\.?\.$/ !/^(?:\.|\.\.)$/ !/^\.$|^\.\.$/ !/(?<=^\.)\.?$/ /^[^.]|[^.]$|.../ /...|^[^.]|[^.]$/ /.{3}|^[^.]|[^.]$/ -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>