On Mar 18, 2005, at 1:02 PM, Christopher Weimann wrote:

On 03/18/2005-10:35AM, Mike Hall wrote:

A caret as the first charachter in a class is a negation. So this [^\s]+ means match one or more of any char that isn't whitespace.


Ok, so the context of metas change within a class. That makes sense, but I'm unclear on the discrepancy below.


The ^ means begining of line EXCEPT inside a charachter class. There it means NOT for the entire class and it only means that if it is the very first charachter. I suppose you could consider that the there are two separate types of char classes. One is started with [ and the other is started with [^.


Got it, thanks.




That would be \


Here's where I'm confused. From the Python docs:

Special characters are not active inside sets. For example, [akm$] will
match any of the characters "a", "k", "m", or "$"



And the next paragraphs says...

You can match the characters not within a range by complementing the
set. This is indicated by including a "^" as the first character of the
class; "^" elsewhere will simply match the "^" character. For example,
[^5] will match any character except "5".




The sad thing is I have read that paragraph before (but obviously hadn't absorbed the significance). I'm new to this, it'll sink in. Thanks.



_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Reply via email to