Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

LINUX C++ REGEXP ÕýÔò±í´ïʽ

ÔÚPOSIXÖУ¬±ãÓÐ×ÅÖ§³ÖÕýÔò±í´ïʽµÄϵͳº¯Êý¡£GNU/LinuxÓÐÁ½Ì׿â¿ÉÓÃÓÚÕýÔò±í´ïʽ±à³Ì£ºPOSIX¿âºÍPCRE¿â¡£Ç°Õß²»ÐèÒªµ¥¶À°²×°£¬Ò»°ãÐèÇó»¹ÊÇÄÜÂú×ãµÄ£¬ËÙ¶ÈÉÔÂýЩ¡£ºóÕßÊǾøºÊ¢ÃûµÄPerlÕýÔò±í´ïʽ¿â£¬¹¦ÄÜÇ¿´ó£¬Æ¥ÅäËٶȿ죬²»¹ý¿ÉÄÜÐèÒªµ¥¶À°²×°¡£
int regcomp (regex_t *compiled, const char *pattern, int cflags)
    
²ÎÊýcompiledÖ»ÓÐÒ»¸ö³ÉÔ±ÊÇÎÒÃÇÐèÒª¹Ø×¢µÄ£¬ÄǾÍÊÇre_nsub£¬´ú±í±àÒëºóµÄ×Ó±í´ïʽÊýÄ¿£¬ÓÉÓÚÎÒÃÇ»¹ÐèÒª±£´æÕû¸öÆ¥Åäµ½µÄģʽ£¬ËùÒÔ×îÖÕÆ¥ÅäµÄÌõÄ¿ÊýÊÇre_nsub¼Ó1¡£cflagsÓÃÀ´ÐÞÊÎÆ¥Åäģʽ£¬¿ÉÈ¡ÖµÈçÏ£º
REG_EXTENDED ÆôÓÃPOSIXÕýÔò¿âÀ©Õ¹£¬¹ØÓÚ¸ÃÀ©Õ¹µÄÏêϸÐÅÏ¢¿É²Î¿¼POSIX¹æ·¶
REG_ICASE ºöÂÔ´óСд
REG_NOSUB ²»Òª´æ´¢×Ó±í´ïʽ
REG_NEWLINE °Ñ»»Ðзû×÷Ϊ¶àÐеķָô·û£¬ÕâÑù'$'¿ÉÆ¥ÅäÿһÐеÄÐÐ⣬'^'Æ¥ÅäÿһÐеÄÐÐÊ×£¬'.'²»Æ¥Åä»»Ðзû£¬[^...]²»Æ¥ÅäÐÂÐС£
²ÎÊýregexÊÇÒ»¸ö×Ö·û´®£¬Ëü´ú±í½«Òª±»±àÒëµÄÕýÔò±í´ïʽ;²ÎÊýpregÖ¸ÏòÒ»¸öÉùÃ÷Ϊregex_tµÄÊý¾Ý½á¹¹£¬ÓÃÀ´±£´æ±àÒë½á¹û;²ÎÊýcflags¾ö¶¨ÁËÕýÔò±í´ïʽ¸ÃÈçºÎ±»´¦ÀíµÄϸ½Ú¡£
¡¡¡¡Èç¹ûº¯Êýregcomp()Ö´Ðгɹ¦£¬²¢ÇÒ±àÒë½á¹û±»ÕýÈ·Ìî³äµ½pregÖк󣬺¯Êý½«·µ»Ø0£¬ÈκÎÆäËüµÄ·µ»Ø½á¹û¶¼´ú±íÓÐijÖÖ´íÎó²úÉú¡£
¡¡¡¡Æ¥ÅäÕýÔò±í´ïʽ
¡¡¡¡Ò»µ©ÓÃregcomp()º¯Êý³É¹¦µØ±àÒëÁËÕýÔò±í´ïʽ£¬½ÓÏÂÀ´¾Í¿ÉÒÔµ÷ÓÃregexec()º¯ÊýÍê³ÉģʽƥÅ䣺
±àÒëÍêģʽºóÎÒÃÇ´ÓÄÚ´æÖзÖÅä×Ó±í´ïʽ´æ´¢¿Õ¼ä£¬È»ºóµ÷ÓÃregexec¶Ô´®½øÐÐÆ¥Å䣬¸Ãº¯ÊýÔ­ÐÍÈçÏ£º
int regexec (regex_t *compiled, char *string, size_t nmatch, regmatch_t matchptr [], int eflags)
nmatchÖ¸Ã÷matchptrÊý×éµÄÊýÄ¿£¬¸ÃÊýÄ¿ÊÇcompiled->re_nsub+1£¬Ò²¿ÉÒÔÈÃnmatchΪ0,matchptrΪNULL£¬±íʾ²»Òª±£´æ×Ó±í´ïʽ¡£eflagsͨ³£Îª0¡£
²ÎÊýpregÖ¸Ïò±àÒëºóµÄÕýÔò±í´ïʽ£¬²ÎÊýstringÊǽ«Òª½øÐÐÆ¥ÅäµÄ×Ö·û´®£¬¶ø²ÎÊýnmatchºÍpmatchÔòÓÃÓÚ°ÑÆ¥Åä½á¹û·µ»Ø¸øµ÷ÓóÌÐò£¬×îºóÒ»¸ö²ÎÊýeflags¾ö¶¨ÁËÆ¥ÅäµÄϸ½Ú¡£
¡¡¡¡ÔÚµ÷Óú¯Êýregexec()½øÐÐģʽƥÅäµÄ¹ý³ÌÖУ¬¿ÉÄÜÔÚ×Ö·û´®stringÖлáÓжദÓë¸ø¶¨µÄÕýÔò±í´ïʽÏàÆ¥Å䣬²ÎÊýpmatch¾ÍÊÇÓÃÀ´±£´æÕâЩƥÅäλÖõģ¬¶ø²ÎÊýnmatchÔò¸æËߺ¯Êýregexec()×î¶à¿ÉÒ԰ѶàÉÙ¸öÆ¥Åä½á¹ûÌî³äµ½pmatchÊý×éÖС£µ±regexec()º¯Êý³É¹¦·µ»Øʱ£¬´Óstring+pmatch[0].rm_soµ½string+pmatch[0].rm_eoÊǵÚÒ»¸öÆ¥ÅäµÄ×Ö·û´®£¬¶ø´Óstring+pmatch[1].rm_soµ½string+pmatch[1].rm_eo£¬ÔòÊǵÚ


Ïà¹ØÎĵµ£º

linuxÄں˶ÁÊé±Ê¼Ç£¨½ø³ÌÖÕÖ¹º¯Êý·ÖÎö£©Èý

do_exit() Function
-----------------------------------------------------------------------
kernel/exit.c
707 NORET_TYPE void do_exit(long code)
708 {
709 struct task_struct *tsk = current;
710
711 if (unlikely(in_interrupt()))
712 panic("Aiee, killing interrupt handler!");
713 if ......

linuxϵͳµ÷ÓÃÁбí

Ò»¡¢½ø³Ì¿ØÖÆ£º
fork
´´½¨Ò»¸öнø³Ì
clone
°´Ö¸¶¨Ìõ¼þ´´½¨×Ó
½ø³Ì
execve
ÔËÐпÉÖ´ÐÐÎļþ
exit
ÖÐ
Ö¹½ø³Ì
_exit
Á¢¼´ÖÐÖ¹µ±Ç°½ø³Ì
getdtablesize
½ø
³ÌËùÄÜ´ò¿ªµÄ×î´óÎļþÊý
getpgid
»ñÈ¡Ö¸¶¨½ø³Ì×é±êʶºÅ
setpgid
Éè
ÖÃÖ¸¶¨½ø³Ì×é±êÖ¾ºÅ
getpgrp
»ñÈ¡µ±Ç°½ø³Ì×é±êʶºÅ
setpgrp
Éè
Öõ±Ç°½ø³Ì×é± ......

LinuxÄÇЩʶùÖ®ÎÒÊÇSysfs(6)Îļþϵͳ

½ÓÏÂÀ´£¬ÎÒÃǽøÈësysfs²¿·Ö¡£¿´¿´
kobject_add()->create_dir()->sysfs_create_dir()
bus create file->sysfs create file()
. . .
ÕâЩsysfsº¯ÊýµÄÄÚÄ»¡£
˵°×ÁË£¬sysfs¾ÍÊÇÀûÓÃVFSµÄ½Ó¿ÚÈ¥¶ÁдkobjectµÄ²ã´Î½á¹¹£¬½¨Á¢ÆðÀ´µÄÎļþϵͳ¡£¹ØÓÚsysfsµÄÄÚÈݾÍÔÚfs/sysfs/Ï¡£&nbs ......

VC++µÄADOÁ¬½ÓAccess²½Öè

1:ÔÚStaAfx.h ÖÐÌí¼ÓÈçÏ´úÂë #import "C:\\Program Files\\Common Files \\System\\ado\\msado15.dll" no_namespace rename("EOF","adoEOF")rename("BOF","adoBOF")
2:ÔÚBOOL CXXXApp::InitInstance()Öгõʼ»¯COM»·¾³
   ::CoInitialize(NULL);
   ÊÍ·ÅCOM»·¾³
   ::CoUninitialize(); ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ