You've marked this solved, but didn't explain why. Did you figure it out? And it would've probably helped if you posted the output you got, as well as what you wanted to get.
As far as I can see, the regex isn't a problem, really. But the way you're setting the arrays is. The command substitution will split on whitespace (unless you reset IFS to avoid it). But that would affect the first line and not the second.
I suggest using
mapfile instead in any case (assuming bash). It's much safer and cleaner.
We can probably also simplify the
sed expressions a bit.
Code:
mapfile -t torrentlink < <( sed -rn '/target=/ { s/.*href="// ; s/".*//p }' <"$html" )
mapfile -t torrentname < <( sed -rn '/target=/ { s/[^>]+>// ; s/[.]torrent<.*//p }' <"$html" )
#test print the lines:
printf '(%s)\n' "${torrentlink[@]}"
echo
printf '(%s)\n' "${torrentname[@]}"
This is the output I get for the above:
Code:
(forum.php?mod=attachment&aid=NzkxNzl8ZGZhMjViZjB8MTM0OTQzMjkyOXw5MDM3MnwxODkxNTQ%3D)
(forum.php?mod=attachment&aid=ODIzNDV8Nzc2OTFhZmR8MTM0OTQzMjk2N3w5MDM3MnwxNzM5ODI%3D)
([DMG][Dog Days`][04][1280x720][BIG5].mp4)
([dmfans][Shirokuma_Cafe][27][848×480][BIG5].rmvb)