RewriteEngine on

RewriteRule ^article/([0-9]+)/([0-9]+)/(.*?).html$ /article.php?articleid=$1&categoryid=$2
I've been trying to find a site that explains what each part of this code does but I can't seem to find it. I understand some of the regular expression, but can't seem to grasp what "$1" or "$2" are for. what do those do? What does the "^" and "$" after the .html serve?

all I know is that it turns this...
HTML Code:
into this...