One single line regex solution would be:
re.sub(r'http\://www.mysite.org/\?page=([^"]+)',r'pages/\1.htm',html)
--
http://mail.python.org/mailman/listinfo/python-list
On 04/30/2010 02:54 PM, KevinUT wrote:
I want to globally change the following:
into:
Normally I'd just do this with sed on a *nix-like OS:
find . -iname '*.html' -exec sed -i.BAK
's...@href="http://www.mysite.org/?page=\([^"]*\)@href="pages/\1@g'
{} \;
This finds all the HTML file
KevinUT wrote:
> Hello Folks:
>
> I want to globally change the following:
>
> into:
>
> You'll notice that the match would be http://www.mysite.org/?page= but
> I also need to add a ".htm" to the end of "contacts" so it becomes
> "contacts.htm" This part of the URL is variable, so how can I
Hello Folks:
I want to globally change the following:
into:
You'll notice that the match would be http://www.mysite.org/?page= but
I also need to add a ".htm" to the end of "contacts" so it becomes
"contacts.htm" This part of the URL is variable, so how can I use a
combination of Python and/or