Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #50731
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin1!goblin.stu.neva.ru!eweka.nl!hq-usenetpeers.eweka.nl!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!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.010 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'output': 0.05; 'string.': 0.05; 'subject:group': 0.05; 'subject:help': 0.08; 'subject:expression': 0.16; 'subject:regular': 0.16; 'subject:python': 0.16; 'skip:= 10': 0.16; 'all,': 0.19; 'import': 0.22; 'print': 0.22; 'script': 0.25; 'appreciated': 0.26; 'correct': 0.29; 'skip:( 40': 0.30; 'message-id:@mail.gmail.com': 0.30; "skip:' 10": 0.31; 'skip:# 10': 0.33; 'received:google.com': 0.35; 'thanks': 0.36; 'to:addr:python-list': 0.38; 'skip:& 20': 0.39; 'to:addr:python.org': 0.39; 'logs': 0.60; 'dear': 0.65; 'here': 0.66; 'groups.': 0.74 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=iV4eF3ADo3DAGDJMPA09WoFOb+kwJIOoK1EbwZIk5CA=; b=gNji2eZSHWcdUZTwskAcKWKApPakmH8corGoAmR8BmGOa1anXkdEhOTHGSOxLj+g3h Y2W7SVfDoFAQ/tUIz50g0wvLNh9khuOSuNWS/wUD8N0PfyHKhjwvnU5cohl4y24eHc+E RegczxIH4ZjPmJBrcx8af9kLayhsq2qmy/NWf+ZDduLsYW7WxJvaAnC5kKKT9+12nLkO z8uUhesicgUyVLAwMLIkB7GnRG0uP1J2nGASvt2piKPIwmnLd0d8eVO+zAxF21KGQH1e NJErUv2iK0iTm7cLgQNrPJfIz+3feUP3NR/iy119iyqHFoNqnjzOXMVTL0wy+EIKd8Im EPeg== |
| MIME-Version | 1.0 |
| X-Received | by 10.68.160.193 with SMTP id xm1mr73443pbb.88.1373957758971; Mon, 15 Jul 2013 23:55:58 -0700 (PDT) |
| Date | Tue, 16 Jul 2013 12:25:58 +0530 |
| Subject | help on python regular expression named group |
| From | Mohan L <l.mohanphy@gmail.com> |
| To | python-list@python.org |
| Content-Type | multipart/alternative; boundary=047d7bd6beee28f77304e19b78d9 |
| X-Mailman-Approved-At | Tue, 16 Jul 2013 09:43:20 +0200 |
| 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.4760.1373960601.3114.python-list@python.org> (permalink) |
| Lines | 118 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1373960601 news.xs4all.nl 15888 [2001:888:2000:d::a6]:34519 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:50731 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
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
Thanks
Mohan L
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
help on python regular expression named group Mohan L <l.mohanphy@gmail.com> - 2013-07-16 12:25 +0530
Re: help on python regular expression named group wxjmfauth@gmail.com - 2013-07-16 23:15 -0700
Re: help on python regular expression named group Joshua Landau <joshua@landau.ws> - 2013-07-17 08:46 +0100
Re: help on python regular expression named group wxjmfauth@gmail.com - 2013-07-17 01:00 -0700
csiph-web