Path: csiph.com!usenet.pasdenom.info!poup.poupinou.org!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1a.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.021 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'syntax': 0.04; 'subject:Python': 0.06; 'modify': 0.07; 'parser': 0.07; 'etc).': 0.09; 'python': 0.11; 'from:addr:hobson42': 0.16; 'from:name:ian': 0.16; 'reply-to:addr:hobson42': 0.16; 'simple.': 0.16; 'write,': 0.16; 'files.': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'all,': 0.19; 'module': 0.19; 'memory': 0.22; 'header:User-Agent:1': 0.23; 'certainly': 0.24; 'parse': 0.24; 'people,': 0.24; 'script': 0.25; 'purposes': 0.26; 'header:In-Reply-To:1': 0.27; 'thus': 0.29; "i'm": 0.30; 'easier': 0.31; 'file': 0.32; 'regular': 0.32; 'could': 0.34; 'received:google.com': 0.35; "i'll": 0.36; 'subject:?': 0.36; 'two': 0.37; 'project': 0.37; 'easily': 0.37; 'message-id:@gmail.com': 0.38; 'jason': 0.38; 'to:addr:python- list': 0.38; 'files': 0.38; 'to:addr:python.org': 0.39; 'future': 0.60; 'ian': 0.60; 'first': 0.61; 'address': 0.63; 'information': 0.63; 'provide': 0.64; 'details': 0.65; 'header:Reply-To:1': 0.67; 'reads': 0.68; 'reply-to:no real name:2**0': 0.71; 'hoping': 0.75; 'reply-to:addr:gmail.com': 0.80; 'bailey': 0.84; 'proofing': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:reply-to:user-agent:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=yYkoPo4R60uOC8X2TjxN41X9dkDqFaw8w9gRbhEFsWQ=; b=hVRoarPylvgtEGpEZT48hXka4McEOuD8bekDbsNE1SitZ2W6oInitqHn/3EPnATNE+ 6EcO7KgRZH7wJbAgF/cBshiHLGi5dRyKDs09lHSHFALr6230Ml3qVSKQWN3868Dfd15b 8xnFxxha1K87caKBQ5yQyDBujSC8s5GLNDlqEwsFyJ5W3NmsXi1gsKKSH4VtH/i1jeQC Q0r7k82hMjDVv268ul8Snkm/5iVT1H5QrXIcX0DrVF9FIdEkf4cuniZy5sg5vGiRV75i GkFG00JJymxeP+PM9NrTZYAF5VNpWyMUFv15dgpHiKt2utnalxnzoi4Qr3gvT1BgpTT1 1fwA== X-Received: by 10.180.74.212 with SMTP id w20mr33789608wiv.22.1421092105761; Mon, 12 Jan 2015 11:48:25 -0800 (PST) Date: Mon, 12 Jan 2015 19:48:18 +0000 From: Ian User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Python 3 regex? References: <54B40C85.5000806@emerytelcom.com> In-Reply-To: <54B40C85.5000806@emerytelcom.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: hobson42@gmail.com 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: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1421092112 news.xs4all.nl 2829 [2001:888:2000:d::a6]:59009 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:83625 On 12/01/2015 18:03, Jason Bailey wrote: > Hi all, > > I'm working on a Python _3_ project that will be used to parse ISC > DHCPD configuration files for statistics and alarming purposes (IP > address pools, etc). Anyway, I'm hung up on this one section and was > hoping someone could provide me with some insight. > > My script first reads the DHCPD configuration file into memory - > variable "filebody". It then utilizes the re module to find the > configuration details for the wanted "shared network". > Hi Jason, If you actually look at the syntax of what you are parsing, it is very simple. My recommendation would be to write a recursive decent parser for your files. That way will be easier to write, much easier to modify and almost certainly faster that a RE solution - and it can easily give you all the information in the file thus future proofing it. 'Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.' - Jamie Zawinski. Regards Ian