2006年11月11日 星期六 22:13
×Ö·û´®£º COMPONENT, '085-317574','0-85-317574',7101 ; GENERAL /KIND_OF_COMP = 'P' /MAT_CODE = 1 ÎÒÏëÆ¥ÅäºìÉ«²¿·Ö£¬Ê¹ÓÃCOMPONENT, (.*),\'È¡µÃµÚÒ»¸öºìÉ«²¿·ÖÒÔºó£¬ÈçºÎºöÂÔµô/KIND_OF_COMPÇ°ÃæµÄÐУ¿/KIND_OF_COMPÇ°ÃæµÄÐÐÊýÊǿɱäµÄ¡£ÇëÖ¸½Ì£¬Ð»Ð»¡£ -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20061111/7d778222/attachment.html
2006年11月13日 星期一 10:02
ΪʲôҪÕâÑùд?ÄãÖ±½ÓÃèÊöºìÉ«²¿·Ö²»ÐÐÂð? _____ ·¢¼þÈË: python-chinese-bounces在lists.python.cn [mailto:python-chinese-bounces在lists.python.cn] ´ú±í makeyunbad ·¢ËÍʱ¼ä: 2006Äê11ÔÂ11ÈÕ 22:14 ÊÕ¼þÈË: python-cn在googlegroups.com; python-chinese Ö÷Ìâ: [python-chinese] ÕýÔò±í´ïʽÈçºÎºöÂÔÈÎÒâÐУ¿ ×Ö·û´®£º COMPONENT, '085-317574','0-85-317574',7101 ; GENERAL /KIND_OF_COMP = 'P' /MAT_CODE = 1 ÎÒÏëÆ¥ÅäºìÉ«²¿·Ö£¬Ê¹ÓÃCOMPONENT, (.*),\'È¡µÃµÚÒ»¸öºìÉ«²¿·ÖÒÔºó£¬ÈçºÎºöÂÔµô /KIND_OF_COMPÇ°ÃæµÄÐУ¿/KIND_OF_COMPÇ°ÃæµÄÐÐÊýÊǿɱäµÄ¡£ÇëÖ¸½Ì£¬Ð»Ð»¡£ -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20061113/03a852a3/attachment.htm
2006年11月13日 星期一 10:20
re.search("COMPONENT,(\'.*?\')[.\n]*?/KIND_OF_COMP=(\'.*?\')",text, re.M)
参数re.M则表示对多行字符串进行匹配
.表示非换行字符
所以[.\n]表示任意字符,包括换行字符,所以可以匹配多行
*?非贪婪匹配
周冲 写道:
>
> 为什么要这样写?你直接描述红色部分不行吗?
>
> ------------------------------------------------------------------------
>
> *发件人:* python-chinese-bounces at lists.python.cn
> [mailto:python-chinese-bounces at lists.python.cn] *代表 *makeyunbad
> *发送时间:* 2006年11月11日 22:14
> *收件人:* python-cn at googlegroups.com; python-chinese
> *主题:* [python-chinese] 正则表达式如何忽略任意行?
>
> 字符串:
>
> COMPONENT, '085-317574','0-85-317574',7101
> ;
>
> GENERAL
> /KIND_OF_COMP = 'P'
> /MAT_CODE = 1
>
> 我想匹配红色部分,使用COMPONENT, (.*),\'取得第一个红色部分以后,如何忽
> 略掉/KIND_OF_COMP前面的行?/KIND_OF_COMP前面的行数是可变的。请指教,谢谢。
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
2006年11月13日 星期一 16:22
re.M¿ÉÒÔºöÂÔ¶àÐÐ ----- Original Message ----- From: makeyunbad To: python-cn在googlegroups.com ; python-chinese Sent: Saturday, November 11, 2006 10:13 PM Subject: [python-chinese] ÕýÔò±í´ïʽÈçºÎºöÂÔÈÎÒâÐУ¿ ×Ö·û´®£º COMPONENT, '085-317574','0-85-317574',7101 ; GENERAL /KIND_OF_COMP = 'P' /MAT_CODE = 1 ÎÒÏëÆ¥ÅäºìÉ«²¿·Ö£¬Ê¹ÓÃCOMPONENT, (.*),\'È¡µÃµÚÒ»¸öºìÉ«²¿·ÖÒÔºó£¬ÈçºÎºöÂÔµô/KIND_OF_COMPÇ°ÃæµÄÐУ¿/KIND_OF_COMPÇ°ÃæµÄÐÐÊýÊǿɱäµÄ¡£ÇëÖ¸½Ì£¬Ð»Ð»¡£ ------------------------------------------------------------------------------ _______________________________________________ python-chinese Post: send python-chinese在lists.python.cn Subscribe: send subscribe to python-chinese-request在lists.python.cn Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn Detail Info: http://python.cn/mailman/listinfo/python-chinese -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20061113/0909a4ee/attachment-0001.htm
Zeuux © 2025
京ICP备05028076号