Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #73808
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2014-07-01 13:49 -0700 |
| References | <mailman.11370.1404227582.18130.python-list@python.org> |
| Message-ID | <f6d1bf0e-1b70-491e-b8a1-3541c039307f@googlegroups.com> (permalink) |
| Subject | Re: Get named groups from a regular expression |
| From | jkn <jkn_gg@nicorp.f9.co.uk> |
On Tuesday, 1 July 2014 16:12:34 UTC+1, Florian Lindner wrote:
> Hello,
>
>
>
> Is there a way I can extract the named groups from a regular expression?
>
> e.g. given "(?P<testgrp>\d)" I want to get something like ["testgrp"].
>
>
>
> OR
>
>
>
> Can I make the match object to return default values for named groups, even
>
> if no match was produced?
>
>
>
> Thanks,
>
> Florian
If you can, my approach would to have a class which you use both to create
the regex (using group names), and return the names of the groups in the
regex you have created.
As I say, this might not be possible in your case though.
Jon N
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Get named groups from a regular expression Florian Lindner <mailinglists@xgm.de> - 2014-07-01 17:12 +0200 Re: Get named groups from a regular expression jkn <jkn_gg@nicorp.f9.co.uk> - 2014-07-01 13:49 -0700 Re: Get named groups from a regular expression Philip Shaw <jnufcvyvuc@tznvy.pbz> - 2014-07-03 23:30 +0000
csiph-web