Regular Expression Detail
===

I'm using a regular expression in my Coffeescript file to detect the presence of any hyperlinks within a block of text. The current expression (credit to Jeff Atwood) that I'm using is:

<code>
///\(?\b(https?://|www.)[-A-Za-z0-9+&@\#/%?=~_()|!:,.;]*[-A-Za-z0-9+&@\#/%=~_()|]///g   
</code>

However, I haven't been able to reference the .replace results with $n (where n is the index of the result). Someone suggested that I replace the leading and ending triple-slash with a single slash, which resulted in this:

<code>
/\(?\b(https?://|www.)[-A-Za-z0-9+&@\#\/%?=~_()|!:,.;]*[-A-Za-z0-9+&@\#\/%=~_()|]/g 
</code>

The second snippet returns a translation error, stating that there is an unmatched ')' Does anyone know what's going on with the $n operator or the second regexp?

Thanks.