9797 >>> 'item' in r
9898 True
9999
100- Note that `in` only works if you have named fields. Dotted names and indexes
101- are possible though the application must make additional sense of the result:
100+ Note that `in` only works if you have named fields.
101+
102+ Dotted names and indexes are possible with some limits. Only word identifiers
103+ are supported (ie. no numeric indexes) and the application must make additional
104+ sense of the result:
102105
103106.. code-block:: pycon
104107
381384
382385----
383386
384- - 1.19.0 Added slice access to fixed results (thanks @jonathangjertsen)
387+ - 1.19.0 Added slice access to fixed results (thanks @jonathangjertsen).
388+ Also corrected matching of *full string* vs. *full line* (thanks @giladreti)
389+ Fix issue with using digit field numbering and types
385390- 1.18.0 Correct bug in int parsing introduced in 1.16.0 (thanks @maxxk)
386391- 1.17.0 Make left- and center-aligned search consume up to next space
387392- 1.16.0 Make compiled parse objects pickleable (thanks @martinResearch)
458463 and removed the restriction on mixing fixed-position and named fields
459464- 1.0.0 initial release
460465
461- This code is copyright 2012-2020 Richard Jones <richard@python.org>
466+ This code is copyright 2012-2021 Richard Jones <richard@python.org>
462467See the end of the source file for the license of use.
463468'''
464469
465470from __future__ import absolute_import
466471
467- __version__ = '1.18 .0'
472+ __version__ = '1.19 .0'
468473
469474# yes, I now have two problems
470475import re
@@ -1032,11 +1037,17 @@ def _handle_field(self, field):
10321037 # now figure whether this is an anonymous or named field, and whether
10331038 # there's any format specification
10341039 format = ''
1035- if field and field [0 ].isalpha ():
1036- if ':' in field :
1037- name , format = field .split (':' )
1038- else :
1039- name = field
1040+
1041+ if ':' in field :
1042+ name , format = field .split (':' )
1043+ else :
1044+ name = field
1045+
1046+ # This *should* be more flexible, but parsing complicated structures
1047+ # out of the string is hard (and not necessarily useful) ... and I'm
1048+ # being lazy. So for now `identifier` is "anything starting with a
1049+ # letter" and digit args don't get attribute or element stuff.
1050+ if name and name [0 ].isalpha ():
10401051 if name in self ._name_to_group_map :
10411052 if self ._name_types [name ] != format :
10421053 raise RepeatedNameError (
@@ -1056,8 +1067,6 @@ def _handle_field(self, field):
10561067 else :
10571068 self ._fixed_fields .append (self ._group_index )
10581069 wrap = r'(%s)'
1059- if ':' in field :
1060- format = field [1 :]
10611070 group = self ._group_index
10621071
10631072 # simplest case: no type specifier ({} or {name})
0 commit comments