i capture every option , text following using following regex. strangely, regex captures numbered options 1 digit. appreciated.
>>> s = '[a] option a\n[1] option 2\n[12] option 12' >>> re.findall('\[([a-z]|[\d\+])\]\s+(.*)?\\r?\\n?', s,re.m) [('a', 'option a'), ('1', 'option 2')]
change [\d\+] \d+, [\d\+] match either single digit or + sign
>>> s = '[a] option a\n[1] option 2\n[12] option 12' >>> re.findall('\[([a-z\d]+)\]\s+(.*)?\\r?\\n?', s) [('a', 'option a'), ('1', 'option 2'), ('12', 'option 12')]
Comments
Post a Comment