On Tue, Jun 17, 2014 at 9:57 PM, Mohan R <mohan...@gmail.com> wrote: > Hello Regex Gurus, > > I need help handling this particular situation > > In a log file, I have a line like this, > > 2014-06-17 13:55:14: IncomingData: TMSUpdateCallback: > { SourceID=JP000456712 Ric=0388.HK BuyQty=3800.0 TradeTime="2014-06-17 > 13:54:19" DestID="" ExchangeTransCode="65725497 89897456 523 1" > Account="PTBHK01" } > > I have to make a dictionary out of this line using the key=value pair > strings between {} parenthesis. I can take out the inner string using > the following code, > > re.search('^.*{ (.*) }.*$', line).groups()[0] > > But, after this, I'm looking for a way to split the string using ' > '(space), but the values also contains ' '(space) in between. I have to > replace the space in the values and split the string using ' '(space). > Is there any way in regex to capture only the values which are inside "" > and contain space?
replace the the string of spaces with *one* space and - something like this "[ ]{1,+}" You can also try sed to search for strings and capture the context in a variable. -- Arun Khan _______________________________________________ ILUGC Mailing List: http://www.ae.iitm.ac.in/mailman/listinfo/ilugc ILUGC Mailing List Guidelines: http://ilugc.in/mailinglist-guidelines