Message: 1 > Date: Tue, 26 Jan 2010 11:33:23 +0100 > From: Wichert Akkerman <wich...@wiggy.net> > To: python-nl@python.org > Subject: Re: [python-nl] Python-nl Digest, Vol 68, Issue 10 > Message-ID: <4b5ec4f3.40...@wiggy.net> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > On 1/26/10 11:31 , Hendrikus Godvliet wrote: > > Hallo Allemaal: > > > > Van de Django meeting naar iets anders de Python module re > > > > In v.b den vindt ik geen antwoord hoe je de module re toepast op een > > file / bestand. > > > >>>> import re > >>>> search_me ="my phone number is 917-555-1234 hey hey" > > > >>>> match_obj = re.search(r"(\d{3})-(\d{3})-(\d{4})", search_me) > > > > Ik zoek naar |zoiets als > > f = open("test.dat", "r")| > > > >>>> import re > >>>> search_me =| open("test.dat","r")| > > > > Graag hier een aanwijzing in? > > python gebruikt geen magische operators. Maar je kan het heel makkelijk > gewoon uitschrijven: > > search_me = open("test.dat").read() > match_obj = re.search(r"(\d{3})-(\d{3})-(\d{4})", search_me) > > Wichert. > > Wichert
Dank voor je hulp - aanwijzing. Waarom het bij niet werkte was omdat ik .read() niet had toegevoegd. import re text = open("datum", "r")*.read()* m = re.match("(\d{2})/(\d{2})/(\d{2,4})", text) if m: print m.group(1, 2, 3) Groet Hendrikus Godvliet
_______________________________________________ Python-nl mailing list Python-nl@python.org http://mail.python.org/mailman/listinfo/python-nl