Python论坛  - 讨论区

标题:[python-chinese] v # invalid expression ????

2004年03月11日 星期四 17:23

zhao bear_sh at eastday.com
Thu Mar 11 17:23:56 HKT 2004

Anthony Liu,ÄúºÃ£¡

	| ºÃÏñÊÇre±í´ïʽÖÐʹÓõķûºÅ£¬ÄãÓ¦¸ÃʹÓÃ\|À´×ªÒå

======= 2004-03-11 17:16:30 ÄúÔÚÀ´ÐÅÖÐдµÀ£º=======

>I am trying to split a string like so:
>
>re.split(',|。|、|!|:|,|?|“|”|)|(|;',
>my_string)
>
>Python complains like so:
>
>Traceback (most recent call last):
>  File "C:\Python23\codes\regextest.py", line 27, in
>-toplevel-
>    ultimate =
>re.split(',|。|、|!|:|,|?|“|”|)|(|;',
>ch[0])
>  File "c:\python23\lib\sre.py", line 156, in split
>    return _compile(pattern, 0).split(string,
>maxsplit)
>  File "c:\python23\lib\sre.py", line 229, in _compile
>    raise error, v # invalid expression
>error: nothing to repeat
>
>Does this mean that the regular expression I pass to
>the split function is not valid?
>
>That expression is just like ',|)|#|!', that is, an
>or-ed list of punctuations. Then why invalid?
>
>
>
>__________________________________
>Do you Yahoo!?
>Yahoo! Search - Find what you’re looking for faster
>http://search.yahoo.com
>
>_______________________________________________
>python-chinese list
>python-chinese at lists.python.cn
>http://python.cn/mailman/listinfo/python-chinese
>

= = = = = = = = = = = = = = = = = = = =
			

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ÖÂ
Àñ£¡
 
				 
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡zhao
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡bear_sh at eastday.com
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡2004-03-11

-------------- next part --------------
A non-text attachment was scrubbed...
Name: fox.gif
Type: image/gif
Size: 9519 bytes
Desc: not available
Url : http://lists.exoweb.net/pipermail/python-chinese/attachments/20040311/5c852138/fox.gif

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2004年03月11日 星期四 17:26

Who Bruce whoonline at msn.com
Thu Mar 11 17:26:42 HKT 2004

It's because that some punctuations are special characters, so maybe you 
should try to use \ to escape special characters, and I also suggest you to 
use raw string which starts with r instead of normal strings for regular 
expressions.

and this always something wrong with your email encoding,why?

>From: Anthony Liu <antonyliu2002 at yahoo.com>
>Reply-To: python-chinese at lists.python.cn
>To: pycn <python-chinese at lists.python.cn>
>Subject: [python-chinese] v # invalid expression ????
>Date: Thu, 11 Mar 2004 01:16:30 -0800 (PST)
>
>I am trying to split a string like so:
>
>re.split(',|¡£|¡¢|!|:|,|?|“|”|)|(|;',
>my_string)
>
>Python complains like so:
>
>Traceback (most recent call last):
>   File "C:\Python23\codes\regextest.py", line 27, in
>-toplevel-
>     ultimate =
>re.split(',|¡£|¡¢|!|:|,|?|“|”|)|(|;',
>ch[0])
>   File "c:\python23\lib\sre.py", line 156, in split
>     return _compile(pattern, 0).split(string,
>maxsplit)
>   File "c:\python23\lib\sre.py", line 229, in _compile
>     raise error, v # invalid expression
>error: nothing to repeat
>
>Does this mean that the regular expression I pass to
>the split function is not valid?
>
>That expression is just like ',|)|#|!', that is, an
>or-ed list of punctuations. Then why invalid?
>
>
>
>__________________________________
>Do you Yahoo!?
>Yahoo! Search - Find what you’re looking for faster
>http://search.yahoo.com
>_______________________________________________
>python-chinese list
>python-chinese at lists.python.cn
>http://python.cn/mailman/listinfo/python-chinese

_________________________________________________________________
ÓëÁª»úµÄÅóÓѽøÐн»Á÷£¬ÇëʹÓà MSN Messenger:  http://messenger.msn.com/cn  



[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2004年03月11日 星期四 18:10

Anthony Liu antonyliu2002 at yahoo.com
Thu Mar 11 18:10:45 HKT 2004

是的,
多谢提醒。

--- zhao <bear_sh at eastday.com> wrote:
> Anthony Liu,您好!
> 
> 	|
好像是re表达式中使用的符号,你应该使用\|来转义
> 
> ======= 2004-03-11 17:16:30
您在来信中写道:=======
> 
> >I am trying to split a string like so:
> >
>
>re.split(',|。|、|!|:|,|?|搢攟)|(|;',
> >my_string)
> >
> >Python complains like so:
> >
> >Traceback (most recent call last):
> >  File "C:\Python23\codes\regextest.py", line 27,
> in
> >-toplevel-
> >    ultimate =
>
>re.split(',|。|、|!|:|,|?|搢攟)|(|;',
> >ch[0])
> >  File "c:\python23\lib\sre.py", line 156, in split
> >    return _compile(pattern, 0).split(string,
> >maxsplit)
> >  File "c:\python23\lib\sre.py", line 229, in
> _compile
> >    raise error, v # invalid expression
> >error: nothing to repeat
> >
> >Does this mean that the regular expression I pass
> to
> >the split function is not valid?
> >
> >That expression is just like ',|)|#|!', that is, an
> >or-ed list of punctuations. Then why invalid?
> >
> >
> >
> >__________________________________
> >Do you Yahoo!?
> >Yahoo! Search - Find what you抮e looking for
faster
> >http://search.yahoo.com
> >
> >_______________________________________________
> >python-chinese list
> >python-chinese at lists.python.cn
> >http://python.cn/mailman/listinfo/python-chinese
> >
> 
> = = = = = = = = = = = = = = = = = = = =
> 			
> 
>
        致
> 礼!
>  
> 				 
>
        zhao
>
        bear_sh at eastday.com
>
          2004-03-11
> 
> 

> ATTACHMENT part 2 image/gif name=fox.gif
> _______________________________________________
> python-chinese list
> python-chinese at lists.python.cn
> http://python.cn/mailman/listinfo/python-chinese
> 


__________________________________
Do you Yahoo!?
Yahoo! Search - Find what you’re looking for faster
http://search.yahoo.com


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2004年03月11日 星期四 18:11

Anthony Liu antonyliu2002 at yahoo.com
Thu Mar 11 18:11:28 HKT 2004

Yes, Who, exactly that is the case.  It works now.

Thanks a lot.

--- Who Bruce <whoonline at msn.com> wrote:
> It's because that some punctuations are special
> characters, so maybe you 
> should try to use \ to escape special characters,
> and I also suggest you to 
> use raw string which starts with r instead of normal
> strings for regular 
> expressions.
> 
> and this always something wrong with your email
> encoding,why?
> 
> >From: Anthony Liu <antonyliu2002 at yahoo.com>
> >Reply-To: python-chinese at lists.python.cn
> >To: pycn <python-chinese at lists.python.cn>
> >Subject: [python-chinese] v # invalid expression
> ????
> >Date: Thu, 11 Mar 2004 01:16:30 -0800 (PST)
> >
> >I am trying to split a string like so:
> >
>
>re.split(',|。|、|!|:|,|?|搢攟)|(|;',
> >my_string)
> >
> >Python complains like so:
> >
> >Traceback (most recent call last):
> >   File "C:\Python23\codes\regextest.py", line 27,
> in
> >-toplevel-
> >     ultimate =
>
>re.split(',|。|、|!|:|,|?|搢攟)|(|;',
> >ch[0])
> >   File "c:\python23\lib\sre.py", line 156, in
> split
> >     return _compile(pattern, 0).split(string,
> >maxsplit)
> >   File "c:\python23\lib\sre.py", line 229, in
> _compile
> >     raise error, v # invalid expression
> >error: nothing to repeat
> >
> >Does this mean that the regular expression I pass
> to
> >the split function is not valid?
> >
> >That expression is just like ',|)|#|!', that is, an
> >or-ed list of punctuations. Then why invalid?
> >
> >
> >
> >__________________________________
> >Do you Yahoo!?
> >Yahoo! Search - Find what you抮e looking for
faster
> >http://search.yahoo.com
> >_______________________________________________
> >python-chinese list
> >python-chinese at lists.python.cn
> >http://python.cn/mailman/listinfo/python-chinese
> 
>
_________________________________________________________________
>
与联机的朋友进行交流,请使用
MSN Messenger: 
> http://messenger.msn.com/cn  
> 
> _______________________________________________
> python-chinese list
> python-chinese at lists.python.cn
> http://python.cn/mailman/listinfo/python-chinese


__________________________________
Do you Yahoo!?
Yahoo! Search - Find what you’re looking for faster
http://search.yahoo.com


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2024

    京ICP备05028076号