for (@links1) { s/<\s*a\s.*?\b(href\s*=\s*".*?").*?>//i; } #### @links1=~ # that would work like scalar(@array)=~ s/ .* # replace complete string with / href # 'href' \s* # as many spacey chars as possible \= # no need to escape '=' \s* # as many spacey chars as possible \" # no need to escape '"' .*? # as few as possible (=no) anythings \" # no need to escape '"' /isx; # 's' is not needed, I added 'x'