/^(?=.*\b<word1>)(?=.*\<word2>)/
- Good for typeahead search with MongoDB, because it matches words in any order. To use, split a query string by spaces, then insert each word into the regex surrounded by parenthesies with forward lookahead ((?=.* )
). Here, I've included the \b which matches the start of a word, to ensure users' results aren't cluttered by random letters in the middle of words. (http://rubular.com/r/hnOalIdRYA)
https://gist.github.com/gruber/8891611 - Best one I've seen for matching web URLS
\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}\b
- Should match just about any email address, except for anyone that decides to put an MX record on a TLD (for example, admin@com would be a possible address that doesn't match this). However, for 99.999% of all use cases, this is preferrable (to make sure that people don't forget to add .com to the end).