Closed GoogleCodeExporter closed 9 years ago
The parsed structure (in the form of a tree) doesn't contain the information
you would need. It doesn't, for example, contain the positions within the
pattern string of the various parts because it has no need for them, and,
anyway, the module then optimises, compiles, and discards it.
Do you know of any other regex implementations which possess such a feature?
Original comment by re...@mrabarnett.plus.com
on 9 Jul 2012 at 12:58
Thanks, I don't know of any regex implementation exposing this information
explicitly. I was just considering possible approaches to achieve this
functionality (as seen in some regex testers/debuggers).
It appeared to me, that regex has a well structured parsing process (in
contrast to the more opaque re) (e.g. judging from the function calls in
tracebacks...), and I thought, such information, or some relevant bits of it,
would be somehow available to the parser at some point.
The ouptput using the DEBUG flag indeed contains useful information, but I
wasn't able to connect it to the pattern parts; although it appears to be
(partly?) segmentable - based on GROUP ... CHARACTER MATCH and possibly others.
However, it is not the case, it certainly shouldn't be added, as this is not a
library business, but that of the application. Do you think, are there some
other approaches possible? Can the parse tree be accessed in regex in some
(semi)official way?
Thanks and regards
vbr
Original comment by Vlastimil.Brom@gmail.com
on 9 Jul 2012 at 9:28
The parse tree is purely an implementation detail.
Original comment by re...@mrabarnett.plus.com
on 9 Jul 2012 at 7:10
There are a number of features which are not represented in the parse tree,
such as the in-line flags and non-capture grouping.
Original comment by re...@mrabarnett.plus.com
on 10 Jul 2012 at 4:50
Original issue reported on code.google.com by
Vlastimil.Brom@gmail.com
on 9 Jul 2012 at 12:34