regular expression

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pavanponnapalli
    New Member
    • May 2008
    • 51

    regular expression

    hi,
    Code:
         my $a = '66.249.65.76 - - [01/Jun/2008:04:07:52 -0400] "GET /cgi-bin/asp/philo/dkbl/search3t?OUTPUT=DF&OUTPUT=TF&POLESPAN=1&createmonth=December&dbname=barth&word=europ%C3%A4ischen HTTP/1.1" 200 12788 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"';
    #my $val=2;
    #my $c = index($a,'"',$val);
    
    #print "$c \n";
    #my $b = substr($a,index($a,"\"",1)+1);
    #print "$b";
    
    if($a =~ /\"(\w*)(\s*)\/(\s*)(\S*)/g)
    { 
     	$a = $&; 
     	#print ">>>>>>>$a<<<<<<";
    }
    while($a =~ /(\w*)\//g)
    { 
    	$a = $';
    	print "<<<$a>>> \n";
    	#print "$1\n";
    	my $i=0;
    	if($a=~/(\w*)(\-)(\w*)/)
    	{
    			push(@arr,join "$2",($1,$3));
    			for (@arr)
    			{
    				push(@arr1,$_);
    			}
    			$i++;
    	} 
    	else
    	{
    		push(@arr1,$1);
    	}
    
    }	
    print "<<<@arr>>>>\n";
    print "@arr1 \n";
    output : cgi-bin bin asp philo dkbl
    I need to reemove bin but not bin in cgi-bin? how can i do that?

    regards,
    pavan
    Last edited by eWish; Aug 18 '08, 01:21 PM. Reason: Please use code tags
  • eWish
    Recognized Expert Contributor
    • Jul 2007
    • 973

    #2
    pavanponnapalli ,

    When posting samples of code you are expected to use the &#91;code]&#91;/code] tags. There are instructions on how to use this to the right when making a post/reply.

    --Kevin

    Comment

    • nithinpes
      Recognized Expert Contributor
      • Dec 2007
      • 410

      #3
      I am not very clear on your requirement. What is the input and what is the desired output?

      Comment

      Working...