Re: re.search - Pattern matching review

2016-06-01 Thread Ganesh Pal
Thanks works fine : ) -- https://mail.python.org/mailman/listinfo/python-list

Re: re.search - Pattern matching review

2016-05-30 Thread Matt Wheeler
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): > >

Re: re.search - Pattern matching review

2016-05-30 Thread Ganesh Pal
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 >

Re: re.search - Pattern matching review

2016-05-29 Thread Matt Wheeler
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

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

2016-05-29 Thread Ganesh Pal
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

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

2016-05-29 Thread Ganesh Pal
> 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()) >>>

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

2016-05-28 Thread Albert-Jan Roskam
> 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

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

2016-05-28 Thread Ganesh Pal
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

re.search - Pattern matching review

2016-05-28 Thread Ganesh Pal
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