Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #109229
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Ganesh Pal <ganesh1pal@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: re.search - Pattern matching review ( Apologies re sending) |
| Date | Sun, 29 May 2016 13:06:50 +0530 |
| Lines | 50 |
| Message-ID | <mailman.19.1464507412.1839.python-list@python.org> (permalink) |
| References | <CACT3xuXhA9U1Cwsw_OUW-Zfu96o-Bd9-OHFas80=M9etB0=bsw@mail.gmail.com> <DUB123-W24AEE854E04581EC90DDE283430@phx.gbl> <CACT3xuU-4oEuwjt8bUA=gkU6c=FdUTYeMrqeDGBpt51p_JjOcg@mail.gmail.com> <CACT3xuW7LaYDOW1z_NzMNmjPxu2cMzh587r358Kxz737PzMUFQ@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de DWxqXxnVhWMi8inzXAVxkwHXixZksgZSKhi0lpz8eAgg== |
| Return-Path | <ganesh1pal@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; 'received:209.85.213.46': 0.07; 'teh': 0.07; 'cc:addr:python-list': 0.09; "'0',": 0.09; 'output': 0.13; '>>>': 0.15; 'skip:p 40': 0.15; '","': 0.16; '(pdb)': 0.16; '2016': 0.16; 'map(int,': 0.16; 'perhaps:': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:sending': 0.16; 'wrote:': 0.16; 'string': 0.17; 'email addr:gmail.com>': 0.18; '>>>': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'am,': 0.23; 'header:In-Reply-To:1': 0.24; 'skip:m 30': 0.27; 'message-id:@mail.gmail.com': 0.27; "skip:' 10": 0.28; 'convert': 0.29; 'print': 0.30; 'code': 0.30; 'retain': 0.33; 'list': 0.34; 'received:google.com': 0.35; 'saved': 0.35; 'skip:* 20': 0.35; 'but': 0.36; 'lines': 0.36; 'received:209.85': 0.36; 'subject:: ': 0.37; 'skip:& 10': 0.37; 'thanks': 0.37; 'received:209.85.213': 0.37; 'wanted': 0.37; 'received:209': 0.38; 'address': 0.61; 'subject: ( ': 0.84; 'subject:review': 0.84; 'albert': 0.91; 'to:addr:hotmail.com': 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; bh=VikPO2mk+gvaYDDAJRAswh+++wn0OosQPo1BcJTJxgg=; b=qdJOLKk3N4SYOwJ/cGdFg3tgN4upfdmuFAPOZur4BTjcgrm040wudstGIRzpK3REs5 1eRiM6GeBYUsQ4vNC3j7rmD5r+MViXXjLmKZaQqqdD4lGJnsTCpZ1gbgLAZ6+bFfJvsh Scqj5Wwcu5i3EecNOmVXQOkZeDSoqg0ZPiiQ9sSsqkYwYxAzrNQmveLlVTerq1lXjTKS ePhAbXPTAB6pjj+rSIEv3QcKkMWMBi7AicZFhnCISR0PUoUy9jp8eIMpPQyVm7B9sj5J XUfNnUGkml9Fttg+w9OzNdVUKZI1l/mpLa4xhNasafZgbbn+Z3btqMFVjNRo17lOa0rV my4A== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=VikPO2mk+gvaYDDAJRAswh+++wn0OosQPo1BcJTJxgg=; b=jtUKmvfKs2/EJS1ERShiJqz4B0EXjF7IQEn9qtWERmUWPPA0AcGkBvliKtbDcCtopC D2Kaqi4HZfUwEY99aViOzbZEbCpNWkzCIbTIrg9OSPE/3RnyqE/zllHXYQeSGrd+5tNV eP5yRFJq1dcSBw2h3wZBamZMXR2Bp5L47WREXmWSJiPXyo/2bG5dMuaklrdWoJlaTZF0 rrR9C9ECXVzLFyANrLlqj+vChUJoolt30mdRuMpGAnE3fQR9zK4T+5nq2q+RHWSJVgYf MVzCNzxsjP309ordsB+qkj+5cwfzcLOjiXxwchOW2TMysTSeQ7mRsBSD+rF0bwm9oDDL xQcw== |
| X-Gm-Message-State | ALyK8tJ3ruR1025/7w6aF9cm+HBfs26vSTjfwfakMcs2Dwfy7Ki0X39P1MnoMLtSth+Y0+KFAVBqW9PdQhcgwg== |
| X-Received | by 10.31.158.1 with SMTP id h1mr12937685vke.5.1464507410291; Sun, 29 May 2016 00:36:50 -0700 (PDT) |
| In-Reply-To | <CACT3xuU-4oEuwjt8bUA=gkU6c=FdUTYeMrqeDGBpt51p_JjOcg@mail.gmail.com> |
| X-Content-Filtered-By | Mailman/MimeDel 2.1.22 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.22 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| X-Mailman-Original-Message-ID | <CACT3xuW7LaYDOW1z_NzMNmjPxu2cMzh587r358Kxz737PzMUFQ@mail.gmail.com> |
| X-Mailman-Original-References | <CACT3xuXhA9U1Cwsw_OUW-Zfu96o-Bd9-OHFas80=M9etB0=bsw@mail.gmail.com> <DUB123-W24AEE854E04581EC90DDE283430@phx.gbl> <CACT3xuU-4oEuwjt8bUA=gkU6c=FdUTYeMrqeDGBpt51p_JjOcg@mail.gmail.com> |
| Xref | csiph.com comp.lang.python:109229 |
Show key headers only | View raw
The matched.groups() will group the pattern based with ","
(Pdb) matched.groups()
*('1', '0', '1375772672', '8192')*
but I wanted to retain the output as *'1,0,1375772672:8192' ,*
(Pdb) matched.groups()
('1', '0', '1375772672', '8192')
(Pdb) matched.group()
'Block Address for 1,0,1376034816:8192 (block *1,0,1375772672:8192*'
Regards,
Ganesh
On Sun, May 29, 2016 at 11:53 AM, Ganesh Pal <ganesh1pal@gmail.com> wrote:
>
>
>
>> Perhaps:
>> map(int, re.search(search_pat, stdout).groups())
>>
>>
>>
> Thanks Albert map saved me many lines of code but map returns a list I
> will have to convert the list to string again
> Below is how Iam planning to teh conversion
> >>> block = map(int, re.search(search_pat, stdout).groups())
> >>> print block
> ['1,2:122']
> >>> s1 = ','.join(str(n) for n in block)
> >>> print s1
> 1,2:122
> >>> str(s1)
> '1,2:122'
>
> Regards,
> Ganesh
>
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: re.search - Pattern matching review ( Apologies re sending) Ganesh Pal <ganesh1pal@gmail.com> - 2016-05-29 13:06 +0530
csiph-web