I found a tinyurl snippet that works by just typing /tinyurl <url>

But i decided to add one for long urls that are posted in a channel.
Problem is, if the url has normal text before or after it IE:

<nick> Check this site out <url>
<nick> <url> This site is good

It picks up the text and the url that returns is wrong, this is what i have

Code:
 on ^1:TEXT:*:#root:{ 
  var %input = $1-
  if ( $regsub(%input,/((?:ftp:\/\/|https?:\/\/|www2?\.)[^&lt;&gt;\.\s]+(?:\.[^&lt;&gt;\.\s]+)+(?:\/[^&lt;&gt;\.\s]+)*)/g,\1\,%input) ) &amp;&amp; ( ($len(%input) &gt; 51) ) { /tinyurl %input }
  haltdef
}
 


any help would be really great, thanks