m/]* # an anchor tag href= # the Href in the anchor (["'])((?:(?!\1).)*)\1 # the value in the href [^>]*> # anything to the end of the anchor [^<>]* # the content in the anchor tag <\/a> # the end of the anchor (?:\s|<[^>]*>)+ # any whitespace or html tags (\d{9}) # the 9 digit number /isxm; my $href = $2; my $number = $3;