[Tutor] Regex help please.

Sean 'Shaleh' Perry shalehperry@attbi.com
Wed, 14 Aug 2002 00:25:16 -0700 (PDT)


On 13-Aug-2002 Nicole Seitz wrote:
> 
>>
>> import re
>> import os
>>
>> list = os.listdir('.') #lists all html documents in this directory
>> input = open(list[0], "rb") #this will be changed to iterate over the list
>> text = input.read()
>> p = re.compile("\?(\d+).htm", re.M)
>> result = p.match(text)
>>
>>
>> Now the last two line were written to test the search pattern
>> "\?(\d+).htm". This will be changed to something like
>> re.sub("\?(\d+).htm","\\1.html",text) later to do onestep swapping.
>>

to nit pick the regex, it should be '\.htm'.  A period in a regex means "any
character".