Thanks works fine : )
--
https://mail.python.org/mailman/listinfo/python-list
On 30 May 2016 at 10:03, Ganesh Pal wrote:
> Thanks Matt for the reply and lovely analysis . I was trying to complicate
> the simple task :(
>
> Here is how the code looks now , the whole idea was just to match the
> pattern and return it
>
>
> def get_block(block):
>
> cmd = "get_block_info
On Sun, May 29, 2016 at 10:32 PM, Matt Wheeler wrote:
>
>
> This doesn't seem to exactly match your code below, i.e. your code is
> attempting to construct a tuple from groups 1 through 4. To meet this
> specification I could just `return re.search('(?<=\(block
> )[^(]*(?=\))', stdout).group()`
>
On 28 May 2016 at 19:12, Ganesh Pal wrote:
> Dear Python friends,
>
> I am on Python 2.7 and Linux . I am trying to extract the address
> "1,5,147456:8192" from the below stdout using re.search
>
> (Pdb) stdout
> 'linux-host-machine-1: Block Address for 1,5,27320320:8192 (block
> 1,5,147456:8192)
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:81
> 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())
>>> p
> Date: Sat, 28 May 2016 23:48:16 +0530
> Subject: re.search - Pattern matching review ( Apologies re sending)
> From: ganesh1...@gmail.com
> To: python-list@python.org
>
> Dear Python friends,
>
> I am on Python 2.7 and Linux . I am trying to extract the address
>
Dear Python friends,
I am on Python 2.7 and Linux . I am trying to extract the address
"1,5,147456:8192" from the below stdout using re.search
(Pdb) stdout
'linux-host-machine-1: Block Address for 1,5,27320320:8192 (block
1,5,147456:8192) --\nlinux-host-machine-1: magic
0xdeaff2fe mark_c
Dear Python friends,
I am on Python 2.7 and Linux . I am trying to extract the address
"1,5,147456:8192" from the below stdout using re.search
(Pdb) stdout
'linux-host-machine-1: Block Address for 1,5,27320320:8192 (block
1,5,147456:8192) --\nlinux-host-machine-1: magic
0xdeaff2fe mark_c