Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #33551
| From | "Joseph L. Casale" <jcasale@activenetwerx.com> |
|---|---|
| Subject | Robust regex |
| Date | 2012-11-19 20:32 +0000 |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.7.1353357285.29569.python-list@python.org> (permalink) |
Trying to robustly parse a string that will have key/value pairs separated
by three pipes, where each additional key/value (if more than one exists)
will be delineated by four more pipes.
string = 'key_1|||value_1||||key_2|||value_2'
regex = '((?:(?!\|\|\|).)+)(?:\|\|\|)((?:(?!\|\|\|).)+)(?:\|\|\|\|)?'
I am not convinced this is the most effective or safest, any opinions would
be greatly appreciated!
jlc
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Robust regex "Joseph L. Casale" <jcasale@activenetwerx.com> - 2012-11-19 20:32 +0000
Re: Robust regex John Gordon <gordon@panix.com> - 2012-11-19 20:50 +0000
RE: Robust regex "Joseph L. Casale" <jcasale@activenetwerx.com> - 2012-11-19 23:37 +0000
csiph-web