![]() |
Available news archives:
comp.lang.tcl
-
comp.lang.python
-
comp.security.firewalls
-
sci.crypt -
comp.lang.php -
comp.lang.javascript
|
|
comp.lang.python archiveRe: regexp for sequence of quoted strings
From: Alexander Schmolck <a.schmolck@gmx.net>
Date: Wed May 25 2005 - 22:55:28 CEST
gry@ll.mit.edu writes:
> I have a string like:
what about {'dog \\', ...} ?
If you don't need to validate anything you can just forget about the commas
The regexp below is a bit too complicated (adapted from something else) but I
In [90]:rex = re.compile(r"'(?:[^\n]|(?<!\\)(?:\\)(?:\\\\)*\n)*?(?<!\\)(?:\\\\)*?'")
In [91]:rex.findall(r"{'the','dog\'s','bite'}")
Otherwise just add something like ",|}$" to deal with the final } instead of a
Alternatively, you could also write a regexp to split on the "','" bit and trim
'as
|