[Regex Expression] Confirmative -- World bundry

String to check:

 

As it turns out, our potential shipmates are extremely superstitious. As such, we do not want anyone to enter certain words in their comments.

Requirements: 

1. Let's start checking for bad words within a sentence. We can begin with 'sink'as our first bad word. We will want to make sure this word is by itself and not part of a larger word.

/\bsink\b/gim

 

2. Looking good, but there are more bad words we need to account for. Let's also check for 'wreck'.

/\b(sink|wreck)\b/gim

 

3. Almost finished. Our final bad word to match is 'disaster'.

/\b(sink|wreck|disaster)\b/gim

-------------------------------------

 

/http(s)?:\/\/(www\.)?twitter(\.com|\.org)\/codeschool/gm

posted @ 2016-03-05 21:42  Zhentiw  阅读(250)  评论(0)    收藏  举报