On 14/04/15 13:21, Steven D'Aprano wrote:
although I would probably want to write it out in verbose mode just in case the requirements did change:r"""(?x) (?# verbose mode) (.+?): (?# capture one or more character, followed by a colon) \s+ (?# one or more whitespace) (\d+) (?# capture one or more digits) (?: (?# don't capture ... ) \s+ (?# one or more whitespace) \(.*?\) (?# anything inside round brackets) )? (?# ... and optional) \s* (?# ignore trailing spaces) """ That's a hint to people learning regular expressions: start in verbose mode, then "de-verbose" it if you must.
New one on me. Where does one find out about verbose mode? I don't see it in the re docs? I see an re.X flag but while it seems to be similar in purpose yet it is different to your style above (no parens for example)? -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
