Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #33551

Robust regex

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <jcasale@activenetwerx.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.083
X-Spam-Evidence '*H*': 0.84; '*S*': 0.00; "skip:' 30": 0.15; 'appreciated!': 0.16; 'exists)': 0.16; 'key/value': 0.16; 'pairs': 0.16; "skip:' 60": 0.16; 'string': 0.17; 'to:name:python- list@python.org': 0.20; 'trying': 0.21; 'parse': 0.22; 'received:24': 0.27; 'received:10.0.0': 0.28; 'separated': 0.29; 'received:10.0': 0.33; 'to:addr:python-list': 0.33; 'charset:us- ascii': 0.36; 'received:10': 0.38; 'to:addr:python.org': 0.39; 'where': 0.40; 'most': 0.61; 'received:unknown': 0.63; 'effective': 0.63; 'more': 0.63; 'opinions': 0.72; 'convinced': 0.93
X-Cloudmark-SP-Filtered true
X-Cloudmark-SP-Result v=1.1 cv=qT60hWcJq2tKMlwzTlfV91MSQCJjCwg5oP07qu3o0oU= c=1 sm=1 a=e0aVyHJSPUcA:10 a=7PYXob_7ZXMA:10 a=BLceEmwcHowA:10 a=kj9zAlcOel0A:10 a=oNw28mxuUhXRB3mVwYQ4Ag==:17 a=xvikjLCXSKQmmrFZnMUA:9 a=CjuIK1q_8ugA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117
From "Joseph L. Casale" <jcasale@activenetwerx.com>
To "python-list@python.org" <python-list@python.org>
Subject Robust regex
Thread-Topic Robust regex
Thread-Index Ac3GkbSdJtdJV0V8Ty+J+1yB/TzXUA==
Date Mon, 19 Nov 2012 20:32:29 +0000
Accept-Language en-US
Content-Language en-US
X-MS-Has-Attach
X-MS-TNEF-Correlator
x-originating-ip [10.0.0.4]
Content-Type text/plain; charset="us-ascii"
Content-Transfer-Encoding quoted-printable
MIME-Version 1.0
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.7.1353357285.29569.python-list@python.org> (permalink)
Lines 15
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1353357285 news.xs4all.nl 6939 [2001:888:2000:d::a6]:57674
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:33551

Show key headers only | View raw


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 | NextNext in thread | Find similar | Unroll thread


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