regexp problem in Python

E

Ehsan

I want to find "http://www.2shared.com/download/1716611/e2000f22/
Jadeed_Mlak14.wmv?tsid=20070803-164051-9d637d11" or 3gp instead of
wmv in the text file like this :
<html>
""some code""
function reportAbuse() {
var windowname="abuse";
var url="/abuse.jsp?link=" + "http://www.2shared.com/file/1716611/
e2000f22/Jadeed_Mlak14.html";
OpenWindow =
window.open(url,windowname,'toolbar=no,scrollbars=no,resizable=no,width=500,height=500,left=50,top=50');
OpenWindow.focus();
}
function startDownload(){
window.location = "http://www.2shared.com/download/1716611/
e2000f22/Jadeed_Mlak14.wmv?tsid=20070803-164051-9d637d11";
//document.downloadForm.submit();
}
</script>
</head>
</html>http://www.2shared.com/download/1716611/e2000f22/
Jadeed_Mlak14.3gp?tsid=20070803-164051-9d637d11"sfgsfgsfgv




I use this pattern :
"http.*?\.(wmv|3gp).*""

but it returns only 'wmv' and '3gp' instead of "http://www.2shared.com/
download/1716611/e2000f22/Jadeed_Mlak14.wmv?
tsid=20070803-164051-9d637d11"

what can I do? what's wrong whit this pattern? thanx for your comments
 
E

Ehsan

I want to find "http://www.2shared.com/download/1716611/e2000f22/ [...]
I use this pattern :
"http.*?\.(wmv|3gp).*""
but it returns only 'wmv' and '3gp' instead of "http://www.2shared.com/
download/1716611/e2000f22/Jadeed_Mlak14.wmv?
tsid=20070803-164051-9d637d11"
what can I do? what's wrong whit this pattern? thanx for your comments

Just a guess, based on too little information: Try "(http.*?\.(wmv|
3gp).*)"

Regards,

-=Dave

no, it doesn't work
 
?

=?iso-8859-1?q?S=F6nmez_Kartal?=

I want to find "http://www.2shared.com/download/1716611/e2000f22/
Jadeed_Mlak14.wmv?tsid=20070803-164051-9d637d11" or 3gp instead of
wmv in the text file like this :
<html>
""some code""
function reportAbuse() {
var windowname="abuse";
var url="/abuse.jsp?link=" + "http://www.2shared.com/file/1716611/
e2000f22/Jadeed_Mlak14.html";
OpenWindow =
window.open(url,windowname,'toolbar=no,scrollbars=no,resizable=no,width=500,height=500,left=50,top=50');
OpenWindow.focus();
}
function startDownload(){
window.location = "http://www.2shared.com/download/1716611/
e2000f22/Jadeed_Mlak14.wmv?tsid=20070803-164051-9d637d11";
//document.downloadForm.submit();
}
</script>
</head>
</html>http://www.2shared.com/download/1716611/e2000f22/
Jadeed_Mlak14.3gp?tsid=20070803-164051-9d637d11"sfgsfgsfgv

I use this pattern :
"http.*?\.(wmv|3gp).*""

but it returns only 'wmv' and '3gp' instead of "http://www.2shared.com/
download/1716611/e2000f22/Jadeed_Mlak14.wmv?
tsid=20070803-164051-9d637d11"

what can I do? what's wrong whit this pattern? thanx for your comments

You could use r'window.location = "(.*?\.(wmv|3gp)";' as your regex
string, I guess..
 
E

Ehsan

You could use r'window.location = "(.*?\.(wmv|3gp)";' as your regex
string, I guess..- Hide quoted text -

- Show quoted text -

I didn't get what do you mean? i think i must just change the pattern
but I don't know how to find bestfit pattern
 
F

Fabio Z Tessitore

Il Fri, 03 Aug 2007 14:41:52 -0700, Ehsan ha scritto:

maybe you can use this to solve your prob:

myurl = "http://www.2shared.com/download/1716611/e2000f22/
Jadeed_Mlak14.wmv?tsid=20070803-164051-9d637d11"

if myurl.startswith('http') and ('wmv' in myurl or '3pg' in myurl):
# myurl is the complete address you want
print myurl

#####################################

about re, I'm waiting for someone enlightening all us,
bye
Fabio
 
?

=?iso-8859-1?q?S=F6nmez_Kartal?=

I didn't get what do you mean? i think i must just change the pattern
but I don't know how to find bestfit pattern

If you append "window.location = " and ';' to your pattern, it would
be more clear to detect it.

r'window.location = "(.*?)";'

.... I have used this and it gave me ....... ""some code""
.... function reportAbuse() {
.... var windowname="abuse";
.... var url="/abuse.jsp?link=" + "http://www.2shared.com/file/
1716611/e2000f22/Jadeed_Mlak14.html";
.... OpenWindow =
....
window.open(url,windowname,'toolbar=no,scrollbars=no,resizable=no,width=500,height=500,left=50,top=50');
.... OpenWindow.focus();
.... }
.... function startDownload(){
.... window.location = "http://www.2shared.com/download/1716611/
e2000f22/Jadeed_Mlak14.wmv?tsid=20070803-164051-9d637d11";
.... //document.downloadForm.submit();
.... }
.... </script>
.... said:

Happy coding
 
A

Ant

what can I do? what's wrong whit this pattern? thanx for your comments

Nothing. There's something wrong with the code you are using the regex
with. Post it and we may be able to help. Like Lawrence has said, it's
likely to be that you are using m.group(1) with your match object
instead of m.group(0) - the former gets the first group (i.e.
everything between the first set of parens - in your case the wmv|3gp
expression), whereas the latter will return the entire match.

Post your actual code, not just the regex.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top