regexpr. and metachars

Asle Pedersen asle at intermedium.com
Wed Nov 1 16:43:37 EST 2000


Asle Pedersen wrote:

> I want to match strings containing regular expressions (regular expr.
> metachars) with regular expressions!! e.g. what regular expression would
> match "\W+" or  "\W+\w{1,2}" ???
>
> thanks,
> /Asle

i seem to have overcome my problem by using different regexp. syntax:

re.compile(r'\\W{') will match the string "\W{"
re.compile('\\W{') will fail to match the string "\W"

why??

/Asle




More information about the Python-list mailing list