PHPÖ§³ÖÁ½ÖÖÕýÔò±í´ïʽ£¬POSIX·ç¸ñµÄÕýÔò±í´ïʽºÍ¼æÈÝPerl·ç¸ñµÄÕýÔò±í´ïʽ¡£ÏÖÔÚÎÒÃÇ´ó¼ÒËù˵µÄÕýÔò±í´ïʽ»ù±¾ÉÏÊÇÖ¸¼æÈÝPerl·ç¸ñ µÄÕýÔò±í´ïʽ¡£POSIX·ç¸ñµÄÕýÔò±í´ïʽ»ù±¾ÉÏûÈËʹÓÃÁË£¬ËùÒÔ´ÓPHP5.3Æð£¬ÒѾ²»ÍƼöʹÓÃÁË£¬¿ÉÄܵ½PHPµÄÏÂÒ»¸ö°æ±¾¾Í»á°ÑÏà¹ØµÄº¯Êýɾ³ý¡£
¹ØÓÚÕýÔò±í´ïʽ£¬ÒòΪ̫¸´ÔÓ£¬ËùÒÔÒÔºóÏëר¿´Ò»±¾ÕýÔòµÄÊ飬ËùÒÔÖ»½éÉܼæÈÝPerl·ç¸ñµÄÕýÔò±í´ïʽµÄһЩº¯Êý¡£
1. ¶¨½ç·û
¶¨
½ç·û±íʾÕýÔò±í´ïʽµÄ¿ªÊ¼ºÍ½á⣬һ°ãÓÃбÏߣ¨/£©±íʾ¡£ÔÚPHPÖУ¨ÆäËüÓïÑÔÔÝʱûÓвâÊÔ¹ý£©£¬ËüÒ²¿ÉÒÔÓÃÆäËüµÄ·ÇÊý×Ö×ÖĸµÄ×Ö·ûÀ´´úÌæ¡£Èç/\d+
/ºÍ#\d+#µÄ±íʾͬһ¸öÕýÔò±í´ïʽ\d+¡£Í¬Ê±£¬Ò²¿ÉÒÔÓÃСÀ¨ºÅ¶Ô£¬ÖÐÀ¨ºÅ¶Ô£¬´óÀ¨ºÅ¶Ô×öΪ¶¨½ç·û£¬Èç[\d+]¡£
2. º¯Êý
Æ¥Å亯Êý£ºpreg_match(); ÒÔ¼°preg_match_all();
Ìæ»»º¯Êý£ºpreg_replace();
²ð·Öº¯Êý£ºpreg_split();
¹ýÂ˺¯Êý£ºpreg_grep();
ʾÀý´úÂ룺
$a = <<< TEXT aaaaaaa 15 bbbbbbb 16 TEXT; $ret = preg_match(/(\w+) (\d+)/, $a, $match); // $ret : 1 // $match : array(aaaaaaa 15¡ä, aaaaaaa, 15¡ä) $ret = preg_match_all(/(\w+) (\d+)/, $a, $match); // $ret : 2 // $match : array( // array(aaaaaaa 15¡ä, bbbbbbb 16¡ä), // array(bbbbbbb, bbbbbbb), // array(15¡ä, 16¡ä), // ) $ret = preg_match_all(/(\w+) (\d+)/, $a, $match, PREG_SET_ORDER); // $ret : 2 // $match : array( // array(aaaaaaa 15¡ä, bbbbbbb, 15¡ä), // array(bbbbbbb 16¡ä, bbbbbbb, 16¡ä), // ) $b = preg_replace(/(\w+) (\d+)/, \1, \2¡ä, $a); // $b : aaaaaaa, 15 // bbbbbbb, 16¡ä $c = preg_split(/\s/, $a); // $c : array(aaaaaaa, 15¡ä, bbbbbbb, 16¡ä) $files = array(aa.txt, bb.xls, cc.txt); $txtFiles = preg_grep(/.*\.txt/, $files); // $txtFiles : array(aa.txt, cc.txt)
ÍƼöÐÅÏ¢
- ¡¾ÊÓƵ²¥·Å¡¿JplayerÊÓƵ²¥·ÅÆ÷µÄʹÓÃ
- memcacheÄÚ´æÔÀí
- Memcache¼¼Êõ·ÖÏí£º½éÉÜ¡¢Ê¹Óᢴ洢¡¢Ëã·¨¡¢ÓÅ»¯....
- php³£ÓÃÕýÔò±í´ïʽ
- phpÐÔÄܼà²âÄ£¿éXHProf
- ÈÃCI¿ò¼ÜÖ§³Öservice²ã
- ʹÓÃPHPÉú³É´øLOGOµÄ¸öÐÔ»¯¶þάÂëͼÏñ
- ¹ØÓÚCodeIgniterÄã¿ÉÄܲ»ÖªµÀµÄ5¸ö֪ʶµã
- Memcache ºÁÃ뼶³¬Ê±¼°ÆäËû³£¼ûÎÊÌâ»ã×Ü
- [PHP±Ê¼Ç]PHPQueryÒ»¸ö´¦ÀíDOMµÄÀûÆ÷
ÈÈÃÅÐÅÏ¢
- nohup: redirecting stderr to stdou....
- ʹÓÃlog_formatΪNginx·þÎñÆ÷ÉèÖøüÏêϸµÄÈÕÖ¾¸ñʽ
- jquery easyUI--dataGrid-Json
- [Ô´´]·ÂGoogle Reader¡¢ÐÂÀË΢²©¡¢ÌÚѶ΢²©µ....
- ÀûÓÃKeepalived+mysql¹¹½¨¸ß¿ÉÓÃMySQLË«Ö÷×Ô¶....
- Nginx+keepalivedʵÏÖ¸ºÔؾùºâºÍË«»úÈȱ¸¸ß¿ÉÓÃ
- jqueryʵÏÖÒ³Ãæ¼ÓÔؽø¶ÈÌõ
- Rolling cURL: PHP²¢·¢×î¼Ñʵ¼ù
- codeigniter ·ÓÉÖÕ¼«ÓÅ»¯(url rewrite)
- linuxÏÂÉèÖÃsshÎÞÃÜÂëµÇ¼
×î½ü¸üÐÂ
- PHP»ñÈ¡Óû§µÄÕæʵIP£¬²¢ÅжÏÊÇ·ñÄÚÍøIP
- PHP ´íÎóÈÕÖ¾ error_log
- ÀûÓÃbigpipe»úÖÆʵÏÖÒ³ÃæÄ£¿éµÄÒì²½äÖȾ chunked¼¼Êõ
- php¿ØÖÆÎļþÏÂÔØËÙ¶È
- js + php ¶ÁÈ¡¡¢²¥·ÅÊÓƵÁ÷ ¼æÈÝfirefox£¬c....
- ¡¾ÊÓƵ²¥·Å¡¿JplayerÊÓƵ²¥·ÅÆ÷µÄʹÓÃ
- UNICODE Óë UTF-8 µÄ¹Øϵ
- memcacheÄÚ´æÔÀí
- Memcache¼¼Êõ·ÖÏí£º½éÉÜ¡¢Ê¹Óᢴ洢¡¢Ëã·¨¡¢ÓÅ»¯....
- phpʹÓÃmb_detect_encoding¼ì²â×Ö·û´®±àÂë
ÆÀÂÛ