Trying to use a before_save in my Post model and then regex to replace anything that looks like an email with the word 'forbidden'. This is to cut down on spam from comments/posts created by users in a discussion board.
It is currently giving me a syntax error; but I am sure it is more than that? How do I fix it?
Post.rb
before_save :remove_emails
# Prevents and replaces any emails or URLs posted by user as <forbidden>
def remove_emails
self.post = post.gsub^(((ht|f)tp(s?))\://)?(www.|[a-zA-Z].)[a-zA-Z0-9\-\.]+\.(com|edu|gov|mil|net|org|biz|info|name|museum|us|ca|uk)(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\;\?\'\\\+&%\$#\=~_\-]+))*$, "forbidden")
end