regular expression problem 
Author Message
 regular expression problem

Hi all
Perl Problem
if i have a variable that is as followed, how do i assign a new
variable equal http:// and end with .hk   , but as the web page is
vary every times, so i think it should stop be4 HTTP/1.0.

GET http://www.*-*-*.com/
Accept: */*
Accept-Language: en-au
Proxy-Connection: Keep-Alive
If-Modified-Since: Sat, 24 May 2003 07:18:51 GMT; length=4848
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0;
Q312461; .NET CLR 1.0.3705)
Host: www.orientaldaily.com.hk
Proxy-Authorization: Basic cHBwOmFhYWFhYQ==



Sun, 20 Nov 2005 09:17:57 GMT  
 regular expression problem

Quote:

> Hi all
> Perl Problem
> if i have a variable that is as followed, how do i assign a new
> variable equal http:// and end with .hk   , but as the web page is
> vary every times, so i think it should stop be4 HTTP/1.0.

> GET http://www.orientaldaily.com.hk/ HTTP/1.0
> Accept: */*
> Accept-Language: en-au
> Proxy-Connection: Keep-Alive
> If-Modified-Since: Sat, 24 May 2003 07:18:51 GMT; length=4848
> User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0;
> Q312461; .NET CLR 1.0.3705)
> Host: www.orientaldaily.com.hk
> Proxy-Authorization: Basic cHBwOmFhYWFhYQ==

Assuming your string is in a variable called "$str" and you want the URL in
$url, then try..
(Not tested...)

$url = ($str =~ m{^GET (.*?) HTTP}s) ? $1 : undef;

Chris
--
My real address is: chris at lowth dot sea oh em
-> OpenSource e-mail virus protection : http://protector.sourceforge.net
-> iptables configuration wizards : http://www.lowth.com/LinWiz



Sun, 20 Nov 2005 13:33:59 GMT  
 regular expression problem

Quote:

> if i have a variable that is as followed,

There *is no* variable following.

Perhaps you meant a variable's _value_ instead?

Variables in Perl start with a "funny character", such as dollar-sign.

Quote:
> how do i assign a new
> variable equal http:// and end with .hk   , but as the web page is
> vary every times, so i think it should stop be4 HTTP/1.0.

> GET http://www.orientaldaily.com.hk/ HTTP/1.0

   my $url = $1 if m#\bGET\s+(.*?)\s+HTTP/1\.0#;

Which will, of course, break for URLs that use a newer version
of the protocol...

--
    Tad McClellan                          SGML consulting

    Fort Worth, Texas



Sun, 20 Nov 2005 15:53:14 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Regular Expression Problem

2. OT: Regular Expression problem

3. Perl regular expression PROBLEM

4. Regular expression problem

5. regular expression problem

6. Regular Expression Problem

7. regular expression problem

8. Regular Expressions Problem

9. Regular expression problem!!!

10. Regular expression problem

11. Regular expression problem in 4.019

12. Regular Expression problem

 

 
Powered by phpBB® Forum Software