Massi
unread,Jul 23, 2012, 12:31:30 PM7/23/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to re...@googlegroups.com
Hi everyone,
I know this question has been asked thousands of times, but in my case
I have some additional requirements to be satisfied. I need to handle
substrings in the form 'string with spaces':'another string with
spaces' as a single token; I mean, if I have this string:
s ="This is a 'simple test':'string which' shows 'exactly my'
problem"
I need to split it as follow (the single quotes must be mantained in
the splitted list):
["This", "is", "a", "'simple test':'string which'", "shows",
"'exactly my'", "problem"]
I've been succesfully handling this situation (in python) with this regex "(?:'[^']*'|[^' ]+)+", but now I have to change it in order to manage the case in which the sequence \\' implies that the single quote is escaped (i.e. not considered as delimiter). If we consider the example above, the situation is the following:
From: "This is a 'sim\\'ple test':'string which' sh\\'ows 'exactly m\\'y'
problem"
To:
["This", "is", "a", "'sim\\'ple test':'string which'", "sh\\'ows",
"'exactly m\\'y'", "problem"]
Any hints on how to achieve this? Thanks in advance!