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: 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" To: "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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 Trying to robustly parse a string that will have key/value pairs separated= =0A= by three pipes, where each additional key/value (if more than one exists)= =0A= will be delineated by four more pipes.=0A= =0A= string =3D 'key_1|||value_1||||key_2|||value_2'=0A= regex =3D '((?:(?!\|\|\|).)+)(?:\|\|\|)((?:(?!\|\|\|).)+)(?:\|\|\|\|)?'= =0A= =0A= I am not convinced this is the most effective or safest, any opinions would= =0A= be greatly appreciated!=0A= =0A= jlc=