Regular expressions

liunx

Guest
Hi im am trying to figure a better way to do the following code it seems so bulky at the moment can someone please give me some suggestions

Thanks
foreach $text (@text) {
$href = <!-- m --><a class="postlink" href="http://www.htmlforums.com/archive/index.php/$text;">http://www.htmlforums.com/archive/index.php/$text;</a><!-- m -->
my @link = ($href =http://www.htmlforums.com/archive/index.php/~ /href="?[^"\s>]*/gi);
$href = <!-- m --><a class="postlink" href="http://www.htmlforums.com/archive/index.php/$link">http://www.htmlforums.com/archive/index.php/$link</a><!-- m -->[0];
$href =http://www.htmlforums.com/archive/index.php/~ s/href="?//i;
$text =~ s/\<[^>]*href[^<]*\>//i;
$text =~ s/\<\/a\>//i;
$href =http://www.htmlforums.com/archive/index.php/~ s/\n//gi;
$text =~ s/\n//gi;
$text=~ s/\s+/ /g;
$text =~ s/\n//gi;
$text =~ s/\\/\\\\/g;
$text =~ s/"/\\"/g;
$text =~ s/'/\\'/g;

foreach $z ("html","smx","shtml","htm") {
if ($href=http://www.htmlforums.com/archive/index.php/~ /\.$z/gi) {next;}
}

foreach $x ("rar","ace","zip","exe") {
if ($href =http://www.htmlforums.com/archive/index.php/~ /\.($x?)$/ig) {$count++;}
}

}You could always use | ('or') to join all your search/replace regexps together.

A quick example:

foreach(my @test = ('hi,\ </a> how are you','I \a m </a>fine'))
{
$_ =~ s/\n|\s+|\\|<\/a\>//gi;
print $_."\n";
}



output:
hi,howareyou
Iamfine


Hope that helps.
 
Top