I have some regex to match Imgur URLS (I think it's right, please tell me if it's not):
http://(?:i\.imgur\.com/(?.*?)\.(?:jpg|png|gif)|imgur\.com/(?:gallery/)?(?.*))$
What I want to do, is search a document for instances that match that regex, but the replace the string imgur without changing anything around it. How can I do this with Javascript?