ÓÅ»¯JavaÖеÄÕýÔò±í´ïʽ
ÔÎĵØÖ·£º http://www.javaworld.com/javaworld/jw-09-2007/jw-09-optimizingregex.html
Èç¹ûÄ㻨·ÑÁËÊýСʱºÍÕýÔò±í´ïʽ×ö¶·Õù£¬Ö»ÊÇΪÁËÈÃËüÍê³ÉËü¼¸ÃëÄھͿÉÒÔÍê³ÉµÄÆ¥Å䣬ÄÇôÕâƪÎÄÕÂÕýÊÇΪÄãÁ¿Éí¶¨×öµÄ¡£Cristian
MocanuÖ¸³öÁËÔÚʲôµØ·½ÕýÔòģʽƥÅä»á·¢ÉúÑÓ³Ù£¬²¢ÇÒ½âÊÍÁËΪʲô¡£È»ºó£¬ËûÑÝʾÁËÈçºÎ×ö¸ü¶àµÄ»ØËõ£¨backtracking£©¶ø²»ÊÇÃÔʧÔÚÆä
ÖУ¬ÈçºÎÓÅ»¯Ì°À·Ä£Ê½ºÍÃãǿģʽ£¨ÒëÕß×¢--Õâ¸ö·ÒëÊÇÔÚÍøÉϲ鵽£¬×ܸоõ²»Ì«ºÏÊÊ£¬ÔÎÄÊÇreluctant
quantifier£©£¬ÒÔ¼°Possessive
quantifiers£¨ÒëÕß×¢--Õâ¸öÓеĵط½³ÆΪÇÀÕ¼Á¿×Ó£©¡¢¶ÀÁ¢·Ö×飨independent
grouping£©ºÍ»·ÊÓ£¨look-around£©ÎªÊ²Ã´ÊÇÄãµÄÅóÓÑ¡£
±àдÕýÔò±í´ïʽ²»½ö½öÊÇÒ»ÖÖ¼¼ÇÉ£¬¸üÊÇÒ»ÖÖÒÕÊõ --Jeffrey Friedl
±¾ÎÄÖУ¬ÎÒ½«½éÉÜһЩÕýÔò±í´ïʽÖÐʹÓÃĬÈϵÄjava.util.regex°üµÄ³£¼ûȱµã¡£ÎÒ½«½âÊÍΪʲô»ØËõ£¨backtracking£©¼ÈÊÇʹÓÃÕýÔò
±í´ïʽ½øÐÐģʽƥÅäµÄ»ù´¡£¬ÓÖÊÇÓ¦ÓóÌÐò´úÂëÖеij£¼ûÆ¿¾±£»ÎªÊ²Ã´ÔÚʹÓÃÌ°À·Ä£Ê½ºÍÃãǿģʽҪѧ»á½÷É÷£¬ÒÔ¼°ËüÊÇÄãÕýÔò±í´ïʽÓÅ»¯µÄÒªËØ¡£È»ºóÎÒ»á½éÉÜÓÅ
»¯ÕýÔò±í´ïµÄ¼¼ÇÉ£¬²¢ÌÖÂÛͨ¹ýJavaģʽƥÅäÒýÇæÔËÐÐеÄÕýÔò±í´ïʽʱ»á·¢Éúʲô¡£
»ùÓÚ±¾ÎĵÄÄ¿µÄ£¬ÎÒ¼ÙÉèÄãÒѾÓÐʹÓÃÕýÔò±í´ïʽµÄ¾Ñ飬²¢ÇÒ¶ÔÔÚJava´úÂëÖÐÓÅ»¯ËüÃDZ§ÓкܴóµÄÐËȤ¡£±¾ÎÄÖ÷Ìâ°üÀ¨¼òµ¥ºÍ×Ô¶¯ÓÅ»¯ÓÅ»¯¼¼ÇÉ£¬ÒÔ¼°ÈçºÎʹ
ÓÃÇÀÕ¼Á¿×Ó£¨possessive quantifiers£©¡¢¶ÀÁ¢·Ö×飨independent
grouping£©ºÍ»·ÊÓ£¨lookarounds£©ÓÅ»¯Ì°À·Ä£Ê½ºÍÃãǿģʽ£¨greedy and reluctant
quantifiers£©¡£¹ØÓÚJavaÖÐÕýÔò±í´ïʽµÄ½éÉÜ£¬Çë²Î¿¼±¾ÎĵÄ×ÊÔ´²¿·Ö¡£
JavaģʽƥÅäÒýÇæºÍ»ØËõ£¨The Java pattern-matching engine and backtracking£©
java.util.regex
°ü
ʹÓÃÒ»ÖÖ³ÆΪ·ÇÈ·¶¨ÐÔµÄÓÐÏÞ×Ô¶¯»ú£¨Nondeterministic Finite
Automaton£¬¼ò³ÆΪNFA£©µÄģʽƥÅäÒýÇæ¡£Ö®ËùÒÔ³Æ֮Ϊ·ÇÈ·¶¨ÐԵģ¬ÊÇÒòΪµ±³¢ÊÔʹÓÃÊäÈëµÄ×Ö·û´®Æ¥ÅäÒ»¸öÕýÔò±í´ïʽʱ£¬Ã¿Ò»¸ö×Ö·û»áÒòΪÕýÔò
±í´ïʽµÄ²»Í¬²¿·Ö¶ø±»¶à´Î¼ì²é¡£ÕâÒ²ÊÇÒ»ÖÖÔÚ.NET¡¢PHP¡¢Perl¡¢PythonºÍRuby±»¹ã·ºÊ¹ÓõÄÒýÇæ¡£Ëü½«´ó²¿·
Ïà¹ØÎĵµ£º
1¡¢ÀàµÄÐÞÊηû·ÖΪ£º¿É·ÃÎÊ¿ØÖÆ·ûºÍ·Ç·ÃÎÊ¿ØÖÆ·ûÁ½ÖÖ¡£
¿É·ÃÎÊ¿ØÖÆ·ûÊÇ£º¹«¹²ÀàÐÞÊηû public
·Ç·ÃÎÊ¿ØÖÆ·ûÓУº³éÏóÀàÐÞÊηû abstract £»×îÖÕÀàÐÞÊηû final
1 £©¹«¹²ÀàÐÞÊηû public £º Java ÓïÑÔÖÐÀàµÄ¿É·ÃÎÊ¿ØÖÆ·ûÖ»ÓÐÒ»¸ö£º public ¼´¹«¹²µÄ¡£Ã¿¸ö Java ³ÌÐòµÄÖ÷À඼±ØÐëÊÇ public Àà×÷Ϊ¹«¹²¹¤¾ß¹©ÆäËüÀàºÍ³ÌÐòÊ¹Ó ......
·´Éä»úÖÆ:ËùνµÄ·´Éä»úÖƾÍÊÇjavaÓïÑÔÔÚÔËÐÐʱӵÓÐÒ»Ïî×Ô¹ÛµÄÄÜÁ¦¡£Í¨¹ýÕâÖÖÄÜÁ¦¿ÉÒÔ³¹µ×µÄÁ˽â×ÔÉíµÄÇé¿öΪÏÂÒ»²½µÄ¶¯×÷×ö×¼±¸¡£ÏÂÃæ¾ßÌå½éÉÜÒ»ÏÂjava
µÄ·´Éä»úÖÆ¡£ÕâÀïÄ㽫µß¸²ÔÀ´¶ÔjavaµÄÀí½â¡£
JavaµÄ·´Éä»úÖƵÄʵÏÖÒª½èÖúÓÚ4¸öÀࣺclass£¬Constructor£¬F ......
1¡¢StringÊÇ×î»ù±¾µÄÊý¾ÝÀàÐÍÂð?
»ù±¾Êý¾ÝÀàÐÍ°üÀ¨byte¡¢int¡¢char¡¢long¡¢float¡¢double¡¢booleanºÍshort¡£
java.lang.StringÀàÊÇfinalÀàÐ͵ģ¬Òò´Ë²»¿ÉÒԼ̳ÐÕâ¸öÀà¡¢²»ÄÜÐÞ¸ÄÕâ¸öÀࡣΪÁËÌá¸ßЧÂʽÚÊ¡¿Õ¼ä£¬ÎÒÃÇÓ¦¸ÃÓÃStringBufferÀà
2¡¢int ºÍ Integer ÓÐʲôÇø±ð
Java ÌṩÁ½ÖÖ²»Í¬µÄÀàÐÍ£ºÒýÓÃÀàÐͺÍÔʼÀàÐÍ£¨ ......
LinuxÅäÖÃjava¿ª·¢Æ½Ì¨
Ò»¡¢°²×°jdk
1.ÏÂÔØ°²×°jdk
£¨1£©¡¢Ê×ÏÈ£¬ÔÚhttp://java.sun.com
ÕÒµ½ÒªÏÂÔصÄjdk£¬ÏÂÔØ×Ô¼ºÐèÒªµÄjdk°æ±¾¡£ÎÒÕâÀïʹÓõÄÊÇjdk6£¬µÃµ½µÄÊÇÒ»¸öÃûΪjdk-6u6-linux-i586-rpm.binµÄÎļþ¡£´ËÎļþµ±Ç°Îª²»¿ÉÔËÐеÄshell script¡£
£¨2£©¡¢¸ü¸ÄȨÏÞ£¬ÌáÈ¡jdk°²×°Îļþ£º
´ò¿ªÖÕ¶ËÔËÐ ......
1¡¢StringÊÇ×î»ù±¾µÄÊý¾ÝÀàÐÍÂð?
»ù±¾Êý¾ÝÀàÐÍ°üÀ¨byte¡¢int¡¢char¡¢long¡¢float¡¢double¡¢booleanºÍshort¡£
java.lang.StringÀàÊÇfinalÀàÐ͵ģ¬Òò´Ë²»¿ÉÒԼ̳ÐÕâ¸öÀà¡¢²»ÄÜÐÞ¸ÄÕâ¸öÀࡣΪÁËÌá¸ßЧÂʽÚÊ¡¿Õ¼ä£¬ÎÒÃÇÓ¦¸ÃÓÃStringBufferÀà
2¡¢int ºÍ Integer ÓÐʲôÇø±ð
Java ÌṩÁ½ÖÖ²»Í¬µÄÀàÐÍ£ºÒýÓÃÀàÐͺÍÔʼÀàÐÍ£¨ ......