Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #50744
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <l.mohanphy@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.003 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; '16,': 0.03; 'output': 0.05; 'string.': 0.05; 'subject:group': 0.05; 'subject:help': 0.08; 'cc:addr:python-list': 0.11; 'python': 0.11; 'subject:expression': 0.16; 'subject:regular': 0.16; 'subject:python': 0.16; 'skip:= 10': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'all,': 0.19; 'import': 0.22; 'email addr:gmail.com>': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'script.': 0.24; 'file.': 0.24; 'cc:2**0': 0.24; 'script': 0.25; '>': 0.26; 'appreciated': 0.26; 'header:In-Reply-To:1': 0.27; 'correct': 0.29; 'skip:( 40': 0.30; 'message- id:@mail.gmail.com': 0.30; "skip:' 10": 0.31; '"': 0.31; 'another': 0.32; 'skip:# 10': 0.33; 'third': 0.33; "can't": 0.35; 'received:google.com': 0.35; 'thanks': 0.36; 'skip:& 10': 0.38; 'pm,': 0.38; 'skip:& 20': 0.39; 'logs': 0.60; 'july': 0.63; 'dear': 0.65; 'here': 0.66; 'groups.': 0.74; 'jul': 0.74; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=pGy9D974ZP0UJI2F4xH3xn2+pylTKk5C4+ettohEaHU=; b=FzpBNx9PMwGs0LPqh5R+/3EL5iOxKgZw1MHqFEu1mmkqB1qcHPdV0eUZHQv2uh/HtX 5j03gt4nOIBdVJvCQWRW8qF004AWaaxfso50kpwr83p5sMkgZ/j9M9+ZSxpo51h8GDf6 bDyZDNxH6hDC2Sb+fahOI5HUerDkd12+d46UmiJ9HnfMGOpuQ6XfJQhuduR3X9ux9d4I dYhCZF9W0GrVOVeG1Nwnz7CTCjHTHGTWAmyT8tgRRHKreQaUdBTG0zRluvDouGEMZrQL KBsk3rxKJTSd3jNC7Jd31a9U52H0zJ+hIDflL7D33dhR/lt3mlTJHQUHr7vdpQD47Zry SLhw== |
| MIME-Version | 1.0 |
| X-Received | by 10.66.254.135 with SMTP id ai7mr1829986pad.185.1373969903975; Tue, 16 Jul 2013 03:18:23 -0700 (PDT) |
| In-Reply-To | <CAN1F8qUpxVuNV-9+9NT1zCzkXQKMMwMtTdCv0+TJ-P9wnigcjg@mail.gmail.com> |
| References | <CADiHtmufOLNysgOP7Qoh70_aT+r3rhKFS=9qgd_AcDNgEFVnqw@mail.gmail.com> <CAN1F8qUpxVuNV-9+9NT1zCzkXQKMMwMtTdCv0+TJ-P9wnigcjg@mail.gmail.com> |
| Date | Tue, 16 Jul 2013 15:48:23 +0530 |
| Subject | Re: help on python regular expression named group |
| From | Mohan L <l.mohanphy@gmail.com> |
| To | Joshua Landau <joshua@landau.ws> |
| Content-Type | multipart/alternative; boundary=047d7b10cf290f050d04e19e4c2e |
| X-Mailman-Approved-At | Tue, 16 Jul 2013 14:48:50 +0200 |
| Cc | python-list <python-list@python.org> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4771.1373978931.3114.python-list@python.org> (permalink) |
| Lines | 143 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1373978931 news.xs4all.nl 15897 [2001:888:2000:d::a6]:49171 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:50744 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
On Tue, Jul 16, 2013 at 2:12 PM, Joshua Landau <joshua@landau.ws> wrote:
> On 16 July 2013 07:55, Mohan L <l.mohanphy@gmail.com> wrote:
> >
> > Dear All,
> >
> > Here is my script :
> >
> > #!/usr/bin/python
> > import re
> >
> > # A string.
> > logs = "date=2012-11-28 time=21:14:59"
> >
> > # Match with named groups.
> > m =
> >
> re.match("(?P<datetime>(date=(?P<date>[^\s]+))\s+(time=(?P<time>[^\s]+)))",
> > logs)
> >
> > # print
> > print m.groupdict()
> >
> > Output:
> > ========
> >
> > {'date': '2012-11-28', 'datetime': 'date=2012-11-28 time=21:14:59',
> 'time':
> > '21:14:59'}
> >
> >
> > Required output :
> > ==================
> >
> > {'date': '2012-11-28', 'datetime': '2012-11-28 21:14:59', 'time':
> > '21:14:59'}
> >
> > need help to correct the below regex
> >
> > (?P<datetime>(date=(?P<date>[^\s]+))\s+(time=(?P<time>[^\s]+)))"
> >
> > so that It will have : 'datetime': '2012-11-28 21:14:59' instead of
> > 'datetime': 'date=2012-11-28 time=21:14:59'
> >
> > any help would be greatly appreciated
>
> Why do you need to do this in a single Regex? Can't you just "
> ".join(..) the date and time?
>
I using another third party python script. It takes the regex from
configuration file. I can't write any code. I have to do all this in single
regex.
Thanks
Mohan L
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: help on python regular expression named group Mohan L <l.mohanphy@gmail.com> - 2013-07-16 15:48 +0530
csiph-web