On Wed, 2014-06-18 at 14:48 +0530, Udaya Kumar wrote:
> How are you? If this is related to office work, then you owe me! :)
> Check whether this fits your req.
Yeah :) I owe you a drink party!!
> result = re.findall("\w+=.+?(?=\s+\w+=|\s+})",feedstr,re.M|re.I|re.X)
wow!! I never thought there is a direct regex solution. thank you very
much. Also, I fixed it today using space-to-underscore-inside-quotes
approach. here is the code,
[code]
#!/usr/bin/env python
import re
line = '{ SourceID=JP000456712 Ric=0388.HK BuyQty=3800.0 TradeTime="2014-06-17
13:54:19" DestID="" ExchangeTransCode="65725497 89897456 523 1"
Account="PTBHK01" }'
line = re.match("^.*{ (.*) }.*$', line).groups()[0]
print dict([word.split('=') for word in re.sub('("(?:[^ "]+ *)+")', lambda x:
x.groups()[0].replace(' ', '_'), data).split(' ')])
[/code]
This is not a straight forward regex solution, not sure this can be
achieved in other languages. Anyway thanks for all those replied and
took time to provide a solution.
Thanks,
Mohan R
_______________________________________________
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc
ILUGC Mailing List Guidelines:
http://ilugc.in/mailinglist-guidelines