>>> regexp = '(([a-z]+):)?([a-z]+)$' >>> import re >>> re.match(regexp, 'smil').group(0,1,2,3) ('smil', None, 's', 'smil') >>> import pre >>> pre.match(regexp, 'smil').group(0,1,2,3) ('smil', None, None, 'smil') Needless to say, I am relying on the third value being None... (My regular expression was actually more like '(?:(?P<prefix>[a-z]+):)?(?P<suffix>[a-z]+)$' and I check for result.group('prefix')) -- Sjoerd Mullender <sjoerd.mullender@oratrix.com>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4