More Regexp help please.
John La Rooy
igetenoughspamalreadythanksjlr at doctor.com
Mon Aug 12 15:28:12 EDT 2002
SA wrote:
> On 8/12/02 10:27 AM, in article 1029208615.592822 at ampungk.ozonline.com.au,
> "John La Rooy" <igetenoughspamalreadythanksjlr at doctor.com> wrote:
>
>>This should get you started
>>
>>re.sub("\?(\d+).htm","\\1.html","?1234.htm")
>>
>>\? matches the ?
>>(\d+) matches 1 or more digits and is substituted for the \\1
>>
>>John
>>
>
> Thank you for the quick start.
>
> One last question can I substitute "?1234.htm" with a string called 'text'?
> The 'text' string contains the contents of an html file that has many links
> like ?1234.htm?
>
> Thanks.
> SA
>
like this?
re.sub("\?(\d+).htm","\\1.html",text)
try it and see.
John
More information about the Python-list
mailing list