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.
_______________________________________________
Python-nl mailing list
Python-nl@python.org
http://mail.python.org/mailman/listinfo/python-nl

Antwoord per e-mail aan