Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #109228

Re: re.search - Pattern matching review ( Apologies re sending)

From Ganesh Pal <ganesh1pal@gmail.com>
Newsgroups comp.lang.python
Subject Re: re.search - Pattern matching review ( Apologies re sending)
Date 2016-05-29 11:53 +0530
Message-ID <mailman.18.1464503019.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>

Show all headers | View raw


> 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


Thread

Re: re.search - Pattern matching review ( Apologies re sending) Ganesh Pal <ganesh1pal@gmail.com> - 2016-05-29 11:53 +0530

csiph-web