Ask yourself (or your favourite search engine) how to do it in JavaScript.

http://www.regular-expressions.info/javascript.html