Tip. Whenever you see the verb .* in your regex pattern, you probably want .*? instead. At least 99% of the time.
.* -- Will gobble up the entire webpage from beginning to end, and then slowly back track one letter at a time until it finds a match.
.*? -- Will march forward one letter at a time until it finds a match, in the normal intuitive way you probably imagine it should.
Compare: .*?
//echo -a $regex(blah blah <title>The quick brown fox jumps over the lazy dog.</title>lol sucker!</title> blah blah, <title>(.*?)</title>) -> $regml(1)
1 -> The quick brown fox jumps over the lazy dog.
and: .* without ?
//echo -a $regex(blah blah <title>The quick brown fox jumps over the lazy dog.</title>lol sucker!</title> blah blah, <title>(.*)</title>) -> $regml(1)
1 -> The quick brown fox jumps over the lazy dog.</title>lol sucker!
You can also add a sanity check to tell the match to give up if it's going to be unrealistically long to find a match. Say, 256 or 512 or 1024 characters. Up to you.
.{1,1024}? is the same as .*? but better.
To make the final output variables a sane length as well, you should use $left() to trim them down if they're too long.
var %title = $left(%title,256), %desc = $left(%desc,256)